Skip to main content
Glama

Token Saver MCP

by jerry426
find-implementations.ts3.66 kB
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' import type { ToolMetadata } from '../types' import { z } from 'zod' import { findImplementations } from '../lsp-implementations' import { normalizeParams } from './utils' /** * Tool metadata for documentation generation * This is parsed by generate-instructions.ts */ export const metadata: ToolMetadata = { name: 'find_implementations', title: 'Find Implementations', category: 'lsp' as const, description: 'Find all implementations of an interface or abstract class.', // Documentation sections docs: { brief: 'Find all concrete implementations of interfaces, abstract classes, or virtual methods', parameters: { uri: 'The file URI in encoded format (e.g., "file:///path/to/file.ts")', line: 'The line number (0-based)', character: 'The character position (0-based)', }, examples: [ { title: 'Find interface implementations', code: `find_implementations({ uri: "file:///src/types/api.ts", line: 15, character: 18 }) // From "interface UserService" -> finds all classes implementing it`, }, { title: 'Find abstract class implementations', code: `find_implementations({ uri: "file:///src/base/component.ts", line: 8, character: 25 }) // From "abstract class BaseComponent" -> finds all extending classes`, }, { title: 'Find method overrides', code: `find_implementations({ uri: "file:///src/services/base.ts", line: 22, character: 12 }) // From "abstract process()" -> finds all overriding implementations`, }, ], workflow: { usedWith: ['get_type_definition', 'get_definition'], followedBy: ['get_references', 'get_hover'], description: 'Essential for understanding polymorphism and finding concrete implementations', }, tips: [ 'Position cursor on interface/abstract class names', 'Works for virtual methods to find overrides', 'Shows all concrete classes implementing the interface', 'Perfect for understanding inheritance hierarchies', ], performance: { speed: '< 200ms for typical interfaces', tokenSavings: '95-99% vs manual inheritance search', accuracy: '100% (compiler-level type analysis)', buffering: 'No buffering needed - typically small responses', }, }, } // Tool handler - single source of truth for execution export async function handler(args: any): Promise<any> { const normalized = normalizeParams(args) const handlerImpl = async ({ uri, line, character }: { uri: string, line: number, character: number }) => { const result = await findImplementations(uri, line, character) if (!result || result.length === 0) { return { content: [{ type: 'text', text: 'No implementations found for the symbol at the specified position.', }], } } return { content: [{ type: 'text', text: JSON.stringify(result), }], } } return handlerImpl(normalized) } // Tool registration function export function register(server: McpServer) { server.registerTool( metadata.name, { title: metadata.title, description: metadata.description, inputSchema: { uri: z.string().describe(metadata.docs.parameters?.uri || 'The file URI in encoded format'), line: z.number().describe(metadata.docs.parameters?.line || 'The line number (0-based)'), character: z.number().describe(metadata.docs.parameters?.character || 'The character position (0-based)'), }, }, handler, ) }

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