Skip to main content
Glama
davidteren

Claude Server MCP

by davidteren

get_context

Retrieve stored context by ID to access persistent information across Claude sessions, with optional project filtering for organized management.

Instructions

Retrieve context by ID and optional project ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID of the context to retrieve
projectIdNoOptional project ID for project contexts

Implementation Reference

  • Main execution handler for the 'get_context' tool: extracts id and optional projectId from arguments, calls getContext, returns context content as text or throws error if not found.
    case 'get_context': {
      const { id, projectId } = request.params.arguments as {
        id: string;
        projectId?: string;
      };
      
      const context = await this.getContext(id, projectId);
    
      if (!context) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          `Context not found with ID: ${id}`
        );
      }
    
      return {
        content: [
          {
            type: 'text',
            text: context.content,
          },
        ],
      };
    }
  • Input schema and metadata definition for the 'get_context' tool, used in list tools response.
    {
      name: 'get_context',
      description: 'Retrieve context by ID and optional project ID',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'ID of the context to retrieve',
          },
          projectId: {
            type: 'string',
            description: 'Optional project ID for project contexts',
          },
        },
        required: ['id'],
      },
    },
  • Core helper method to load and parse a specific context JSON file by ID and optional projectId, returning null if not found.
    private async getContext(id: string, projectId?: string): Promise<Context | null> {
      try {
        const contextPath = await this.getContextPath(id, projectId);
        const data = await fs.readFile(contextPath, 'utf-8');
        return JSON.parse(data);
      } catch (error) {
        if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
          return null;
        }
        throw error;
      }
    }
  • Helper to compute the file path for a context, creating project directory if needed.
    private async getContextPath(id: string, projectId?: string): Promise<string> {
      if (projectId) {
        const projectDir = path.join(this.projectsDir, projectId);
        await fs.mkdir(projectDir, { recursive: true });
        return path.join(projectDir, `${id}.json`);
      }
      return path.join(this.contextsDir, `${id}.json`);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('retrieve') but lacks behavioral details such as whether this is a read-only operation, error handling, permissions needed, or rate limits. The description is minimal and doesn't compensate for the absence of annotations.

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 extremely concise with a single sentence that directly states the tool's purpose. It's front-loaded and wastes no words, making it efficient for quick understanding.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'context' entails, the return format, or how it interacts with sibling tools. For a tool with 2 parameters and behavioral uncertainty, more context is needed to be fully helpful.

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 fully documents both parameters. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain context types or project relationships). Baseline 3 is appropriate as the schema handles parameter documentation.

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

Purpose4/5

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

The description clearly states the verb ('retrieve') and resource ('context'), specifying it's done by ID with an optional project ID. However, it doesn't differentiate from sibling tools like 'list_contexts' or 'save_conversation_context', which would require more specific scope or purpose details.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description mentions an optional project ID but doesn't explain when to include it or how this tool differs from siblings like 'list_contexts' or save operations.

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/davidteren/claude-server'

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