Effect Q&A MCP Server
Fetches category data from a Q&A service API and returns a markdown summary grouped by category.
README
Effect Q&A MCP Server
A Model Context Protocol (MCP) server that exposes a single tool: get-categories-summary. Fetches category data from a Q&A service API and returns a markdown summary grouped by category.
Quick Start
# Install dependencies
bun install
# Start the MCP server (requires QA_SERVICE_URL)
QA_SERVICE_URL=https://your-qa-api.example.com bun run index.ts
# Run tests
bun run test
# Type-check
npx tsc --noEmit
# Format code
bun run fmt
Architecture Overview
Component Diagram
graph TB
subgraph "MCP Client"
Client[MCP Client<br/>(Claude, Cursor, etc.)]
end
subgraph "MCP Server Process"
Server[McpServer.layerHttp<br/>:3000/mcp]
Tool[get-categories-summary<br/>Tool Handler]
ApiClient[ApiClient Service<br/>fetchCategories]
HttpClient[NodeHttpClient.layer<br/>Platform HTTP]
end
subgraph "External"
QA_API[Q&A Service API<br/>GET /api/v1/categories]
end
Client <-- MCP over HTTP --> Server
Server --> Tool
Tool --> ApiClient
ApiClient --> HttpClient
HttpClient --> QA_API
Layer Stack (Inner → Outer)
The server is composed as an Effect Layer stack. Each layer provides services to the layers above it.
graph TB
subgraph "Layer Stack"
L5[Layer 5: registerTool<br/>Tool Registration]
L4[Layer 4: ApiClient.Default<br/>Q&A API Client]
L3[Layer 3: McpServer.layerHttp<br/>MCP Protocol @ /mcp]
L2[Layer 2: NodeHttpServer.layer<br/>Node HTTP Server]
L1[Layer 1: NodeHttpClient.layer<br/>Platform HTTP Transport]
end
L1 --> L2
L2 --> L3
L3 --> L4
L4 --> L5
style L1 fill:#f9f,stroke:#333
style L2 fill:#bbf,stroke:#333
style L3 fill:#bfb,stroke:#333
style L4 fill:#ff9,stroke:#333
style L5 fill:#f96,stroke:#333
| Layer | Responsibility | Provides |
|---|---|---|
1. NodeHttpClient.layer |
Platform HTTP transport (fetch, connections, pooling) | HttpClient.HttpClient |
2. NodeHttpServer.layer |
Node.js HTTP server listening on MCP_PORT (default 3000) |
HttpServer.HttpServer |
3. McpServer.layerHttp |
MCP protocol handler at /mcp endpoint |
McpServer.McpServer |
4. ApiClient.Default |
Q&A API client with config (QA_SERVICE_URL, QA_API_KEY) |
ApiClient |
5. registerTool |
Wires get-categories-summary handler to MCP server |
— (side effect) |
Module Structure
src/
├── index.ts — MCP server setup, layer composition, entry point
├── api-client.ts — Effect.Service for Q&A API (errors, HTTP adapter)
├── summary.ts — Pure function: Category[] → markdown string
├── types.ts — Effect Schema definitions (Category, CategoriesResponse)
└── services.ts — Reserved for future top-level services
test/
├── index.test.ts — buildSummary tests + handler with nock
└── summary.test.ts — buildSummary edge cases
Data Flow
sequenceDiagram
participant Client as MCP Client
participant Server as MCP Server
participant Tool as get-categories-summary
participant ApiClient as ApiClient
participant HttpClient as HttpClient
participant QA as Q&A API
Client->>Server: POST /mcp {method: "tools/call", params: {name: "get-categories-summary"}}
Server->>Tool: invoke handler
Tool->>ApiClient: fetchCategories()
ApiClient->>HttpClient: execute GET /api/v1/categories
HttpClient->>QA: HTTP Request
QA-->>HttpClient: 200 OK {data: [...]}
HttpClient-->>ApiClient: HttpClientResponse
ApiClient->>ApiClient: filterStatusOk → decode JSON → Schema.decode
ApiClient-->>Tool: CategoriesResponse
Tool->>Tool: buildSummary(categories.data)
Tool-->>Server: CallToolResult {content: [TextContent]}
Server-->>Client: MCP Response
Configuration
| Environment Variable | Required | Description |
|---|---|---|
QA_SERVICE_URL |
Yes | Base URL of Q&A API (e.g., https://qa.example.com) |
QA_API_KEY |
No | Bearer token for authenticated requests |
MCP_PORT |
No | HTTP listen port (default: 3000) |
Error Handling
The tool handler folds all errors into CallToolResult with isError: true:
| Error Type | Trigger | User-Facing Message |
|---|---|---|
HttpError |
Non-2xx HTTP status | Error fetching categories: HTTP <status> |
DecodeError |
Schema validation failed | Error fetching categories: unexpected response format — <details> |
UnknownError |
Transport/DNS/timeout/JSON parse | Error fetching categories: <message> |
Tool Specification
get-categories-summary
- Description: Fetches categories from the Q&A service and returns a narrative summary grouped by category
- Input: None (empty object)
- Annotations:
readOnlyHint: true— clients may cache/replay - Output: Markdown string via
TextContent
Example Output:
Found 3 categories across 2 groups.
## bugs (2)
- **Login Issue**: Cannot log in
- **Crash**: App crashes on start
## features (1)
- **Dark Mode**: Add dark theme
Testing
# Unit tests (pure functions)
bun run test
# With coverage
bun run test:coverage
Test strategy:
buildSummary— pure function tests (empty, single, multi-category)- Handler — integration test with
nockintercepting HTTP toQA_SERVICE_URL
Development
# Format check
bun run fmt:check
# Type-check
npx tsc --noEmit
# Regenerate docs
bun run docs
Dependencies
Runtime
@effect/ai— MCP server implementation@effect/platform-node— Node.js platform layers (HTTP client/server)effect— Core Effect-TS (services, layers, schemas, errors)
Dev
@effect/vitest— Effect-native testing (it.effect,assert)nock— HTTP mocking for integration testsoxfmt— Formatter (printWidth 120, no semicolons)@effect/language-service— IDE support via tsconfig plugin
License
Private — internal tooling.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。