feat(TRUEREF-0011): implement MCP server with stdio transport

Adds a Model Context Protocol server that exposes resolve-library-id
and query-docs tools via stdio, with tool schemas identical to context7
for drop-in compatibility with Claude Code, Cursor, and Zed.

- src/mcp/index.ts — server entry point (io.github.trueref/trueref)
- src/mcp/client.ts — HTTP client for TrueRef REST API (TRUEREF_API_URL)
- src/mcp/tools/resolve-library-id.ts — library search tool handler
- src/mcp/tools/query-docs.ts — documentation retrieval tool handler
- src/mcp/index.test.ts — integration tests spawning real server subprocess
- .claude/rules/trueref.md — Claude Code rule file for MCP usage
- package.json: mcp:start script using tsx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-03-22 18:32:20 +01:00
parent 956b2a3a62
commit cb253ffe98
8 changed files with 1626 additions and 31 deletions

View File

@@ -14,6 +14,7 @@
"format": "prettier --write .",
"test:unit": "vitest",
"test": "npm run test:unit -- --run",
"mcp:start": "tsx src/mcp/index.ts",
"db:push": "drizzle-kit push",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
@@ -49,6 +50,8 @@
"vitest-browser-svelte": "^2.0.2"
},
"dependencies": {
"better-sqlite3": "^12.6.2"
"@modelcontextprotocol/sdk": "^1.27.1",
"better-sqlite3": "^12.6.2",
"zod": "^4.3.6"
}
}