dummy-nest-mcp
A minimal MCP server built with NestJS to test PostHog MCP analytics integration, exposing mocked tools for trends and funnel analysis.
README
dummy-nest-mcp
A minimal MCP server built with @rekog/mcp-nest (NestJS), instrumented with @posthog/mcp to validate that PostHog's MCP analytics SDK works against a MCP-Nest server.
It exposes two mocked tools — get_trends and get_funnel
How the integration works
MCP-Nest creates the underlying @modelcontextprotocol/sdk McpServer for you. It exposes
that instance through the serverMutator option on McpModule.forRoot():
// src/app.module.ts
McpModule.forRoot({
name: 'dummy-nest-mcp',
version: '0.1.0',
// Stateful Streamable HTTP: one McpServer / one session spans the whole
// connection, so `initialize` and every tool call share an `mcp-session-id`.
// Without this combo (stateless mode, or no propagated session) each request
// stands alone — every tool call is its own session and identify() has no
// stable session to attribute events to.
transport: McpTransportType.STREAMABLE_HTTP,
streamableHttp: { enableJsonResponse: true },
serverMutator: instrumentationMutator, // <- the hook @posthog/mcp plugs into
})
// src/posthog.ts
export const instrumentationMutator = (server) => {
instrument(server, posthog, { logger, identify });
return server;
};
instrument() accepts the high-level McpServer, is idempotent per server instance, and wraps
its request handlers so tool calls / listings / initialize / identity get auto-captured.
⚠️ Subtle bit: because this server is stateful, MCP-Nest builds a fresh
McpServerfor every session, soserverMutator(and thereforeinstrument()) runs once per session, not once at boot. Keep thePostHogclient a shared singleton outside the mutator — see Gotcha 2 below.
Setup
npm install
cp .env.example .env # then put your key in .env
Set in .env:
POSTHOG_PROJECT_TOKEN— your Project token (phc_…), shown under "Project token & ID" in the PostHog UI. This is the value the SDK ingests events with. (POSTHOG_API_KEYis still accepted as a fallback name. Don't use a personal key,phx_….)POSTHOG_HOST— optional. Defaults to PostHog Cloud US (https://us.i.posthog.com). EU:https://eu.i.posthog.com; local dev stack:http://localhost:8010.PORT— optional, defaults to3000.
Run
npm start
# -> server.ready http://localhost:3000/mcp
Tool-call logs (get_trends …) and [posthog] capture lines go to stderr — leave it running.
Test it (curl)
Streamable HTTP is stateful here, so propagate the mcp-session-id returned by initialize:
B=http://localhost:3000/mcp
H='Accept: application/json, text/event-stream'
# initialize → grab the session id from the response header
SID=$(curl -s -D /tmp/h.txt -o /dev/null -H "$H" -H 'Content-Type: application/json' -X POST "$B" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"curl","version":"1.0.0"}}}'; \
grep -i '^mcp-session-id:' /tmp/h.txt | awk '{print $2}' | tr -d '\r')
curl -s -H "$H" -H 'Content-Type: application/json' -H "mcp-session-id: $SID" -X POST "$B" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
curl -s -H "$H" -H 'Content-Type: application/json' -H "mcp-session-id: $SID" -X POST "$B" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_trends","arguments":{"event":"pageview","days":3}}}'
Connect from Claude Desktop
Bridge stdio → HTTP with mcp-remote (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"dummy-nest-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/mcp", "--transport", "http-only"]
}
}
}
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。