Skip to main content
Glama
initial-context-guard.ts744 B
/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Tool as FastMCPTool, ToolParameters, Context } from 'fastmcp'; let initialContextSet = false; export function initialContextGuard(tool: FastMCPTool<any, ToolParameters>): typeof tool { if (tool.name === 'get_initial_context') { return { ...tool, execute: async (args: any, context: Context<any>) => { initialContextSet = true; return tool.execute(args, context); }, }; } return { ...tool, execute: async (args: any, context: Context<any>) => { if (!initialContextSet) { throw new Error('Initial context has not been set. You must call get_initial_context before using this tool.'); } return tool.execute(args, context); }, }; }

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

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