Skip to main content
Glama
index.js2.12 kB
#!/usr/bin/env node import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; import { captionsTool, handleCaptionsTool } from './tools/captions-tool.js'; import { workbookTools, handleWorkbookTools } from './tools/workbook-tools.js'; import { watchtowerTools, handleWatchtowerTools } from './tools/watchtower-tools.js'; import { searchBibleBooksTool, getBibleVerseTool, getVerseWithStudyTool, getBibleVerseURLTool, handleScriptureTools } from './tools/scripture-tools.js'; // Create server instance const server = new Server( { name: 'jw-mcp', version: '1.0.0', }, { capabilities: { tools: {}, }, } ); // Collect all tools from different modules const allTools = [ captionsTool, ...workbookTools, ...watchtowerTools, searchBibleBooksTool, getBibleVerseTool, getVerseWithStudyTool, getBibleVerseURLTool ]; // Collect all tool handlers const toolHandlers = [ handleCaptionsTool, handleWorkbookTools, handleWatchtowerTools, handleScriptureTools ]; // Register tools server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; }); // Handle tool calls by delegating to appropriate handlers server.setRequestHandler(CallToolRequestSchema, async (request) => { // Try each handler until one returns a result for (const handler of toolHandlers) { const result = await handler(request); if (result !== null) { return result; } } // If no handler matched, return error return { content: [ { type: 'text', text: `Unknown tool: ${request.params.name}`, }, ], isError: true, }; }); // Start the server async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error('JW MCP Server running on stdio'); } main().catch((error) => { console.error('Server error:', error); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/advenimus/jw-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server