Skip to main content
Glama

test-1

by zhendi
main.ts1.43 kB
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 { TOOLS, TOOL_HANDLERS } from './tools'; import { log } from './utils/helpers'; const server = new Server( { name: 'tinypng', version: '1.0.0', }, { capabilities: { tools: {} }, }, ); server.setRequestHandler(ListToolsRequestSchema, async () => { log('Received list tools request'); return { tools: TOOLS }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { const toolName = request.params.name; log('Received call tool request, toolName:', toolName); try { return await TOOL_HANDLERS[toolName](request); } catch (error) { log('Error handling tool call:', error); return { toolResult: { content: [ { type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }, }; } }); export async function main() { log('Starting server...'); try { const transport = new StdioServerTransport(); log('Transport created'); await server.connect(transport); log('Server connected'); } catch (error) { log('Fatal 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/zhendi/tinypng-mcp-server'

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