MCP server for exposing discourse graphs to AI assistants. Supports any discourse graph with dynamic node schemas and relationship types.
src/index.ts- Main MCP server entry point, tool registrationsrc/tools.ts- Tool handlers and schemas for all 9 toolssrc/search.ts- Keyword search implementation with sortingsrc/dataLoader.ts- JSON data loading and indexingsrc/imageParser.ts- Firebase image URL extractionsrc/types.ts- TypeScript types and node type schemas
search_nodes- Full-text search with filters and sorting (by created/modified/title)get_node- Get complete node details (includes key image inline)get_linked_nodes- Graph traversal with typed relationshipsget_schema- Return ontology/node typesget_researcher_contributions- Attribution and statisticsget_node_images- Get all images for a node (inline display)get_relationships- Query typed relationshipsget_relation_types- List relationship type definitionsget_node_neighborhood- K-hop neighborhood traversal (BFS, 1-4 hops)
Images are returned as native MCP image content blocks (base64-encoded) rather than URLs. This allows MCP clients (Claude Code, etc.) to render images directly inline in chat responses.
Key implementation in tools.ts:
fetchImageAsBase64()- Fetches image URL and converts to base64handleGetNode()- Returns key image (first image) as inline contenthandleGetNodeImages()- Returns all images as inline content blocks
npm run build # Compile TypeScript
npm start # Run MCP serverData file path can be set via DATA_PATH environment variable, defaults to JSON file in project root.
Server name can be set via SERVER_NAME environment variable. If not provided, the server automatically derives the name from the dataset filename prefix (e.g., discourse-graphs_query-results_*.json → discourse-graphs-server).
DATA_PATH=/path/to/dataset.json npm startDifferent MCP client configurations can launch multiple server instances with different datasets:
{
"mcpServers": {
"discourse-graphs": {
"command": "node",
"args": ["/Users/makamats/Repos/MCP-DG-demo/dist/index.js"],
"env": {
"DATA_PATH": "/Users/makamats/Repos/MCP-DG-demo/discourse-graphs_query-results_202512290038.json"
}
},
"akamatsulab": {
"command": "node",
"args": ["/Users/makamats/Repos/MCP-DG-demo/dist/index.js"],
"env": {
"DATA_PATH": "/Users/makamats/Repos/MCP-DG-demo/akamatsulab_query-results_202512290139.json"
}
}
}
}Server names will be auto-generated as:
discourse-graphs-serverakamatsulab-server