Skip to main content
Glama
index.js1.87 kB
import { ghostToolDefinitions, ghostToolHandlers } from './ghost-tools.js'; import { CallToolRequestSchema, ListToolsRequestSchema, McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; /** * Register all tool handlers with the server * @param {Object} server - The GhostServer instance */ export function registerToolHandlers(server) { // Register tool definitions server.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ghostToolDefinitions, })); // Register tool call handler server.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name === 'list_tools') { return { tools: ghostToolDefinitions, }; } const handler = ghostToolHandlers[request.params.name]; if (handler) { return handler(server, request.params.arguments); } else { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } }); } // Export all tool definitions export const toolDefinitions = ghostToolDefinitions; // Export all tool handlers export const toolHandlers = ghostToolHandlers; /** * Returns a formatted list of all available Ghost tools with their descriptions * @returns {Array} Array of objects containing tool name and description */ export function getToolsList() { return ghostToolDefinitions.map(tool => ({ name: tool.name, description: tool.description })); } /** * Logs all available Ghost tools to the console */ export function showTools() { console.log('Available Ghost Tools:'); console.log('====================='); ghostToolDefinitions.forEach(tool => { console.log(`- ${tool.name}: ${tool.description}`); }); }

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/oculairmedia/Ghost-MCP'

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