Skip to main content
Glama

Token Saver MCP

by jerry426
migrate-tool.ts5.78 kB
#!/usr/bin/env tsx /** * Helper script to migrate tools from monolithic files to modular structure */ // Tool migration templates const LSP_TOOL_TEMPLATE = `import { Server } from '@modelcontextprotocol/sdk/server/index.js' import { z } from 'zod' import { {{importName}} } from '../../lsp' import { bufferResponse } from '../buffer-manager' import { Uri } from 'vscode' /** * Tool metadata for documentation generation */ export const metadata = { name: '{{toolName}}', title: '{{title}}', category: 'lsp' as const, description: '{{description}}', docs: { brief: '{{brief}}', parameters: {{parameters}}, examples: [ { title: '{{exampleTitle}}', code: \`{{exampleCode}}\` } ], workflow: { usedWith: {{usedWith}}, followedBy: {{followedBy}}, description: '{{workflowDesc}}' }, tips: {{tips}}, performance: { speed: '{{speed}}', tokenSavings: '{{tokenSavings}}', accuracy: '100% (semantic understanding)' } } } {{schemaExport}} export function register(server: Server) { server.registerTool( metadata.name, { title: metadata.title, description: metadata.description, inputSchema: schema, }, async (params: z.infer<typeof schema>) => { {{implementation}} } ) } ` const CDP_TOOL_TEMPLATE = `import { Server } from '@modelcontextprotocol/sdk/server/index.js' import { z } from 'zod' import { {{importName}} } from '../../browser-tools' /** * Tool metadata for documentation generation */ export const metadata = { name: '{{toolName}}', title: '{{title}}', category: '{{category}}' as const, description: '{{description}}', docs: { brief: '{{brief}}', parameters: {{parameters}}, examples: [ { title: '{{exampleTitle}}', code: \`{{exampleCode}}\` } ], workflow: { usedWith: {{usedWith}}, followedBy: {{followedBy}}, description: '{{workflowDesc}}' }, tips: {{tips}} } } {{schemaExport}} export function register(server: Server) { server.registerTool( metadata.name, { title: metadata.title, description: metadata.description, inputSchema: schema, }, async (params: z.infer<typeof schema>) => { {{implementation}} } ) } ` // Tool configurations for migration const TOOL_CONFIGS = { // LSP Tools get_completions: { category: 'lsp', importName: 'getCompletions', brief: 'Get code completion suggestions', usedWith: ['get_hover', 'get_definition'], followedBy: ['get_definition'], workflowDesc: 'Used for IDE-like code completion features', tips: ['Results can be large - may be buffered', 'Position must be precise'], speed: '< 100ms', tokenSavings: '95-99%', }, get_definition: { category: 'lsp', importName: 'getDefinition', brief: 'Jump to symbol definition', usedWith: ['search_text', 'get_references'], followedBy: ['get_hover', 'rename_symbol'], workflowDesc: 'Navigate from usage to declaration', tips: ['Use after search_text to find exact location', 'Returns array of possible definitions'], speed: '< 50ms', tokenSavings: '99%', }, get_type_definition: { category: 'lsp', importName: 'getTypeDefinition', brief: 'Navigate to type definition', usedWith: ['get_definition', 'get_hover'], followedBy: ['find_implementations'], workflowDesc: 'Understand type hierarchy and interfaces', tips: ['Useful for TypeScript/strongly-typed languages', 'May return interface or class definition'], speed: '< 50ms', tokenSavings: '99%', }, get_hover: { category: 'lsp', importName: 'getHover', brief: 'Get type info and documentation', usedWith: ['get_definition', 'get_references'], followedBy: ['get_type_definition'], workflowDesc: 'Understand symbols without navigation', tips: ['Provides JSDoc comments', 'Shows inferred types'], speed: '< 50ms', tokenSavings: '95%', }, get_references: { category: 'lsp', importName: 'getReferences', brief: 'Find all usages of a symbol', usedWith: ['get_definition', 'rename_symbol'], followedBy: ['rename_symbol'], workflowDesc: 'Understand impact before refactoring', tips: ['Essential before renaming', 'Shows all imports and usages'], speed: '< 200ms', tokenSavings: '99%', }, search_text: { category: 'lsp', importName: 'searchText', brief: 'Search text patterns across workspace', usedWith: [], followedBy: ['get_definition', 'get_references'], workflowDesc: 'Starting point for code discovery', tips: ['Supports regex patterns', 'Use glob to filter file types', 'Start here when exploring'], speed: '< 500ms', tokenSavings: '90%', }, // CDP Tools navigate_browser: { category: 'cdp', importName: 'navigateBrowser', brief: 'Navigate to URL and wait', usedWith: ['click_element', 'type_in_browser'], followedBy: ['test_react_component', 'get_dom_snapshot'], workflowDesc: 'First step in browser automation', tips: ['Auto-launches Chrome if needed', 'Waits for page load'], }, execute_in_browser: { category: 'cdp', importName: 'executeInBrowser', brief: 'Run JavaScript in browser', usedWith: ['navigate_browser'], followedBy: ['get_browser_console'], workflowDesc: 'Direct browser manipulation', tips: ['Can navigate and execute in one call', 'Returns execution result'], }, } export async function migrateToolsToModular() { // Implementation would go here console.log('Migration helper ready') } if (require.main === module) { migrateToolsToModular().catch(console.error) }

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/jerry426/token-saver-mcp'

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