Skip to main content
Glama
transparentlyok

MCP Context Manager

get_class

Retrieve class definitions and specific methods without reading entire files to reduce token usage by 80%+ in code navigation.

Instructions

⭐ PREFERRED OVER Read: Get class definition without reading the entire file. Optionally filter specific methods. Saves 80%+ tokens vs reading full files. Use this when you need class structure or specific class methods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
classNameYesThe name of the class to retrieve
methodsNoOptional: specific method names to include. If omitted, returns all methods.
filePathNoOptional: specific file path if known

Implementation Reference

  • The actual implementation of the getClass logic that searches the index and retrieves class definitions.
    async getClass(
      className: string,
      methods?: string[],
      filePath?: string
    ): Promise<string> {
      const symbols = this.indexer.findSymbols(className, 'class');
    
      if (symbols.length === 0) {
        return `Class "${className}" not found in index.`;
      }
    
      let targetSymbol: Symbol;
    
      if (filePath) {
        // Normalize path to handle Windows vs Unix separators
        const normalizedInput = path.normalize(filePath);
        const matches = symbols.filter((s) => path.normalize(s.filePath) === normalizedInput);
        if (matches.length === 0) {
          return `Class "${className}" not found in file "${filePath}".\nFound in: ${symbols.map((s) => s.filePath).join(', ')}`;
        }
        targetSymbol = matches[0];
      } else {
        if (symbols.length > 1) {
          const locations = symbols.map((s) => `  - ${s.filePath}:${s.line}`).join('\n');
          return `Multiple classes named "${className}" found:\n${locations}\n\nPlease specify filePath to get the exact class.`;
        }
        targetSymbol = symbols[0];
      }
    
      // If specific methods requested, extract only those
      if (methods && methods.length > 0) {
        return this.extractClassMethods(targetSymbol, methods);
      }
    
      return this.formatSymbolWithContext(targetSymbol);
    }
    
    async getRelevantContext(query: string, maxTokens: number): Promise<string> {
      // Use advanced search engine
      const allSymbols = this.getAllSymbols();
      const files = this.indexer.getAllFiles();
    
      const searchOptions: SearchOptions = {
        maxResults: 50, // Get more candidates, then filter by tokens
        fuzzyThreshold: 0.7,
  • src/index.ts:198-220 (registration)
    Registration of the 'get_class' tool definition including schema.
    {
      name: 'get_class',
      description: '⭐ PREFERRED OVER Read: Get class definition without reading the entire file. Optionally filter specific methods. Saves 80%+ tokens vs reading full files. Use this when you need class structure or specific class methods.',
      inputSchema: {
        type: 'object',
        properties: {
          className: {
            type: 'string',
            description: 'The name of the class to retrieve',
          },
          methods: {
            type: 'array',
            items: { type: 'string' },
            description: 'Optional: specific method names to include. If omitted, returns all methods.',
          },
          filePath: {
            type: 'string',
            description: 'Optional: specific file path if known',
          },
        },
        required: ['className'],
      },
    },
  • Tool handler switch case that calls retriever.getClass.
    case 'get_class': {
      const a = args as any;
      const className: string = a.className || a.name;
      const methods: string[] | undefined = a.methods;
      const filePath: string | undefined = a.filePath || a.path || a.file;
      if (!className) {
        return {
          content: [{ type: 'text', text: 'Error: className is required. Provide the name of the class to retrieve.' }],
          isError: true,
        };
      }
      const result = await retriever.getClass(className, methods, filePath);
      return {
        content: [
          {
            type: 'text',
            text: result,
          },
        ],
      };
    }
    
    case 'get_relevant_context': {
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a read operation ('Get'), offers optional filtering, and highlights efficiency gains ('Saves 80%+ tokens'). However, it doesn't mention potential limitations like error handling or performance constraints, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded, with every sentence earning its place. It starts with a key benefit ('PREFERRED OVER Read'), explains the tool's function, quantifies efficiency, and ends with usage guidance—all in three efficient sentences with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is largely complete. It covers purpose, usage, and benefits well. However, without an output schema, it doesn't explain return values (e.g., format of class definitions), which is a minor gap in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by implying filtering capabilities ('Optionally filter specific methods') but doesn't provide additional syntax or format details. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get class definition', 'filter specific methods') and resources ('class structure', 'class methods'). It distinguishes from siblings by explicitly mentioning 'PREFERRED OVER Read' and contrasting with reading entire files, making its scope unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool ('when you need class structure or specific class methods') and when not to use it (vs. reading full files). It names an alternative ('Read') and quantifies the benefit ('Saves 80%+ tokens'), giving clear context for selection among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/transparentlyok/mcp-context-manager'

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