Skip to main content
Glama

MCPDB - Database Access MCP Server

by jantuitman
mcp-server.js2.11 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'; // Create MCP server const server = new Server( { name: 'mcpdb-server', version: '1.0.0', }, { capabilities: { tools: {}, }, } ); // Add tool handlers server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'add', description: 'Adds two integers and returns the result', inputSchema: { type: 'object', properties: { x: { type: 'integer', description: 'First integer to add', }, y: { type: 'integer', description: 'Second integer to add', }, }, required: ['x', 'y'], }, }, ], }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (name === 'add') { const { x, y } = args; // Validate parameters if (typeof x !== 'number' || typeof y !== 'number') { throw new Error('Both x and y must be numbers'); } if (!Number.isInteger(x) || !Number.isInteger(y)) { throw new Error('Both x and y must be integers'); } // Perform calculation const result = x + y; return { content: [ { type: 'text', text: `${x} + ${y} = ${result}`, }, ], }; } throw new Error(`Unknown tool: ${name}`); }); // Error handling process.on('SIGINT', async () => { await server.close(); process.exit(0); }); process.on('SIGTERM', async () => { await server.close(); process.exit(0); }); // Start server async function main() { const transport = new StdioServerTransport(); await server.connect(transport); } main().catch((error) => { console.error('Server error:', error); process.exit(1); });

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/jantuitman/mcpdb'

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