Skip to main content
Glama
kazuph

MCP Docs RAG Server

by kazuph

add_text_file

Add a text file to the docs directory by specifying a URL and a document name, enabling integration into the MCP Docs RAG Server for context-aware LLM queries.

Instructions

Add a text file to the docs directory with a specified name. Please do not use 'docs' in the document name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_nameYesName of the document (will be used as directory name). Choose a descriptive name rather than using the URL filename (e.g. 'hono' instead of 'llms-full.txt')
file_urlYesURL of the text file to download

Implementation Reference

  • Handler for executing the 'add_text_file' tool. Validates inputs, calls downloadFile helper to add the text file as a document, and returns success or 'already exists' message.
    case "add_text_file": {
      const fileUrl = String(request.params.arguments?.file_url);
      const documentName = String(request.params.arguments?.document_name);
      
      if (!fileUrl) {
        throw new Error("File URL is required");
      }
      
      if (!documentName) {
        throw new Error("Document name is required");
      }
      
      const result = await downloadFile(fileUrl, documentName);
      
      // If document already exists, inform the user without updating
      if (result.exists) {
        return {
          content: [{
            type: "text",
            text: `Document '${result.name}' already exists. Please use list_documents to view existing documents.`
          }]
        };
      }
      
      return {
        content: [{
          type: "text",
          text: `Added document '${result.name}' with content from ${fileUrl}. The index will be created when you query this document for the first time.`
        }]
      };
    }
  • src/index.ts:411-428 (registration)
    Registration of the 'add_text_file' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema.
    {
      name: "add_text_file",
      description: "Add a text file to the docs directory with a specified name. Please do not use 'docs' in the document name.",
      inputSchema: {
        type: "object",
        properties: {
          file_url: {
            type: "string",
            description: "URL of the text file to download"
          },
          document_name: {
            type: "string",
            description: "Name of the document (will be used as directory name). Choose a descriptive name rather than using the URL filename (e.g. 'hono' instead of 'llms-full.txt')"
          }
        },
        required: ["file_url", "document_name"]
      }
    }
  • Helper function downloadFile that implements the core logic of downloading a text file from URL to a document directory as 'index.txt', checking if already exists.
    export async function downloadFile(fileUrl: string, documentName: string): Promise<{ name: string; exists: boolean }> {
      // ドキュメント用のディレクトリを作成
      const docDir = path.join(DOCS_PATH, documentName);
      
      // ディレクトリが存在する場合は更新せずに通知
      if (fs.existsSync(docDir)) {
        return { name: documentName, exists: true };
      }
      
      // ディレクトリが存在しない場合は作成
      fs.mkdirSync(docDir, { recursive: true });
      
      // ファイル名を取得(URLのパス部分の最後)
      const fileName = path.basename(fileUrl);
      
      // index.txtとしてファイルを保存
      const filePath = path.join(docDir, 'index.txt');
      
      // ファイルをダウンロード
      await execAsync(`cd "${docDir}" && wget -O "index.txt" ${fileUrl}`);
      
      return { name: documentName, exists: false };
    }
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 mentions the tool adds a file and downloads from a URL, but doesn't disclose behavioral traits like error handling (e.g., invalid URLs, duplicate names), permissions needed, or side effects (e.g., overwriting existing files). The constraint about 'docs' is helpful but insufficient for a mutation tool.

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

Conciseness4/5

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

The description is brief and front-loaded with the core action, followed by a specific constraint. Both sentences are relevant, with no wasted words, though it could be slightly more structured (e.g., separating action from constraints).

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 mutation tool with two parameters, the description is incomplete. It lacks details on return values, error conditions, or operational context (e.g., how files are stored, success indicators), leaving gaps for an agent to invoke it correctly.

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 both parameters fully. The description adds no additional meaning beyond the schema's details for 'document_name' and 'file_url', such as format examples or usage tips, meeting the baseline for high coverage.

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 ('Add a text file') and target location ('to the docs directory'), with a specific naming constraint. It distinguishes from sibling tools like 'add_git_repository' (different resource) and 'list_documents'/'rag_query' (different actions), though it doesn't explicitly contrast them.

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 a constraint ('do not use 'docs' in the document name') but offers no guidance on when to use this tool versus alternatives like 'add_git_repository' for repositories or 'list_documents' for viewing. It lacks context on prerequisites or typical use cases.

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

Related 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/kazuph/mcp-docs-rag'

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