Skip to main content
Glama
handlePrompt.ts1.33 kB
// Import just the types we need import { graphqlHandlers } from "./promptHandlers/graphql" // Define the correct interfaces to match SDK requirements interface MessageContent { type: "text" text: string } interface Message { role: "user" | "assistant" content: MessageContent } // Define interface for tool objects with required properties interface ToolObject { function: { name: string description?: string parameters?: Record<string, unknown> } } export interface PromptResult { messages: Message[] tools?: ToolObject[] // Properly typed tools array } /** * Handle a prompt request and return the appropriate response * @param name Prompt name * @param args Optional arguments provided for the prompt * @returns Prompt result with messages */ // Tools will be added by the server code at runtime const emptyToolsArray: ToolObject[] = [] export async function handlePrompt( name: string, args?: Record<string, string>, ): Promise<PromptResult> { let result: PromptResult // Handle GraphQL-related prompts only if (name in graphqlHandlers) { result = graphqlHandlers[name as keyof typeof graphqlHandlers](args) } else { throw new Error(`Unknown prompt: ${name}`) } // Tools will be added by the server code result.tools = emptyToolsArray return result }

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/ivo-toby/contentful-mcp-graphql'

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