Skip to main content
Glama
davidteren

Claude Server MCP

by davidteren

list_contexts

Retrieve and filter available contexts in Claude Server MCP by project, tag, or type to manage persistent conversations and project organization.

Instructions

List contexts with filtering options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoOptional project ID to filter by
tagNoOptional tag to filter by
typeNoOptional type to filter by

Implementation Reference

  • Core implementation of listContexts: scans project and conversation directories for JSON files, parses contexts, applies filters for projectId/tag/type, sorts by recency.
    private async listContexts(options: {
      projectId?: string;
      tag?: string;
      type?: 'project' | 'conversation';
    } = {}): Promise<Context[]> {
      await this.ensureDirectories();
      
      const getContextsFromDir = async (dir: string): Promise<Context[]> => {
        const files = await fs.readdir(dir);
        const contexts: Context[] = [];
        
        for (const file of files) {
          if (file.endsWith('.json')) {
            const data = await fs.readFile(path.join(dir, file), 'utf-8');
            contexts.push(JSON.parse(data));
          }
        }
        
        return contexts;
      };
    
      let contexts: Context[] = [];
      
      if (options.projectId) {
        const projectDir = path.join(this.projectsDir, options.projectId);
        contexts = await getContextsFromDir(projectDir);
      } else if (options.type === 'project') {
        contexts = await getContextsFromDir(this.projectsDir);
      } else if (options.type === 'conversation') {
        contexts = await getContextsFromDir(this.contextsDir);
      } else {
        const projectContexts = await getContextsFromDir(this.projectsDir);
        const conversationContexts = await getContextsFromDir(this.contextsDir);
        contexts = [...projectContexts, ...conversationContexts];
      }
    
      if (options.tag) {
        contexts = contexts.filter(ctx => ctx.tags?.includes(options.tag!));
      }
    
      return contexts.sort((a, b) => 
        new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
      );
    }
  • Input schema defining optional parameters for filtering contexts: projectId, tag, type.
    inputSchema: {
      type: 'object',
      properties: {
        projectId: {
          type: 'string',
          description: 'Optional project ID to filter by',
        },
        tag: {
          type: 'string',
          description: 'Optional tag to filter by',
        },
        type: {
          type: 'string',
          enum: ['project', 'conversation'],
          description: 'Optional type to filter by',
        },
      },
    },
  • src/index.ts:268-289 (registration)
    Registration of the list_contexts tool in the ListTools response, including name, description, and schema.
    {
      name: 'list_contexts',
      description: 'List contexts with filtering options',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: {
            type: 'string',
            description: 'Optional project ID to filter by',
          },
          tag: {
            type: 'string',
            description: 'Optional tag to filter by',
          },
          type: {
            type: 'string',
            enum: ['project', 'conversation'],
            description: 'Optional type to filter by',
          },
        },
      },
    },
  • Dispatcher handler in CallToolRequest that parses arguments, calls listContexts, and returns JSON string of results.
    case 'list_contexts': {
      const { projectId, tag, type } = request.params.arguments as {
        projectId?: string;
        tag?: string;
        type?: 'project' | 'conversation';
      };
    
      const contexts = await this.listContexts({ projectId, tag, type });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(contexts, null, 2),
          },
        ],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a read operation with filtering but doesn't disclose critical details like pagination, rate limits, authentication needs, or what 'list contexts' entails (e.g., format, scope). This leaves significant gaps for agent understanding.

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 front-loads the core purpose ('List contexts') and adds a brief qualifier ('with filtering options'). There is zero wasted verbiage, making it highly efficient.

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, no output schema, and a read operation with filtering, the description is incomplete. It lacks details on return values, error handling, or behavioral constraints, leaving the agent with insufficient context to use the tool effectively beyond basic parameter input.

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 all three optional parameters (projectId, tag, type with enum). The description adds no additional meaning beyond implying filtering exists, matching the baseline for high schema coverage without extra param insights.

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 action ('List contexts') and mentions filtering capabilities, which distinguishes it from simple listing operations. However, it doesn't explicitly differentiate from sibling tools like 'get_context' (which might retrieve a single context) or the save operations, missing full sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_context' for single context retrieval or the save tools for creation. It mentions filtering options but doesn't specify scenarios or prerequisites for usage.

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