Skip to main content
Glama
commands.ts1.39 kB
import { z } from 'zod'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { registry } from '../utils/registry.js'; // 注册命令执行工具 export function registerCommandTool(server: McpServer) { server.tool( 'executeCommand', '执行指定的命令', { type: z.string().describe('命令类型'), params: z.record(z.any()).optional().describe('命令参数') }, async ({ type, params = {} }) => { try { const result = await registry.executeCommand(type, params); return { content: [ { type: 'text' as const, text: result.content[0].text } ], _meta: { result: result._meta || {} }, isError: result.isError }; } catch (error) { return { content: [ { type: 'text' as const, text: error instanceof Error ? error.message : '命令执行失败' } ], isError: true }; } } ); }

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/onigeya/siyuan-mcp-server'

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