Skip to main content
Glama
xiaolai
by xiaolai

get_file_context

Retrieve comprehensive file context including sessions, decisions, mistakes, and commits to support manuscript analysis and writing assistance.

Instructions

Get all context for a file (sessions, decisions, mistakes, commits)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathNoPath to manuscript directory (defaults to current directory)
file_pathYesFile to get context for

Implementation Reference

  • The main handler function for the 'get_file_context' MCP tool. Extracts the file_path argument and delegates execution to WritersAid.getFileContext.
    private async getFileContext(args: Record<string, unknown>) {
      const filePath = args.file_path as string;
    
      return this.writersAid.getFileContext({ filePath });
    }
  • Input schema and metadata definition for the 'get_file_context' tool, defining parameters like file_path.
      name: "get_file_context",
      description: "Get all context for a file (sessions, decisions, mistakes, commits)",
      inputSchema: {
        type: "object",
        properties: {
          project_path: { type: "string", description: "Path to manuscript directory (defaults to current directory)" },
          file_path: { type: "string", description: "File to get context for" },
        },
        required: ["file_path"],
      },
    },
  • Core implementation of getFileContext: performs a holistic search across sessions, decisions, mistakes, and commits layers for the given filePath, then categorizes the results.
    async getFileContext(filePath: string): Promise<{
      recentSessions: SearchResult[];
      recentDecisions: SearchResult[];
      recentMistakes: SearchResult[];
      commits: SearchResult[];
    }> {
      const results = await this.search({
        query: filePath,
        layers: ["sessions", "decisions", "mistakes", "commits"],
        limit: 5,
      });
    
      const byLayer = {
        recentSessions: results.results.filter((r) => r.layer === "sessions"),
        recentDecisions: results.results.filter((r) => r.layer === "decisions"),
        recentMistakes: results.results.filter((r) => r.layer === "mistakes"),
        commits: results.results.filter((r) => r.layer === "commits"),
      };
    
      return byLayer;
    }
  • Delegation method in WritersAid class that forwards getFileContext call to the HolisticSearcher instance.
    async getFileContext(options: { filePath: string }) {
      return this.holisticSearcher.getFileContext(options.filePath);
    }
  • Dispatch case in handleTool switch statement that routes 'get_file_context' calls to the handler method.
    case "get_file_context":
      return this.getFileContext(args);

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/xiaolai/claude-writers-aid-mcp'

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