Skip to main content
Glama
masseater
by masseater

upload_content

Add text content to a knowledge base for RAG indexing, making it searchable and retrievable through AI applications.

Instructions

Upload text content to the FileSearchStore for RAG indexing. The content will be processed and made searchable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesText content to upload to the knowledge base
displayNameYesDisplay name for the content in the store
metadataNoCustom metadata as key-value pairs. Values can be strings or numbers. Maximum 20 entries per document. Example: {"category": "guide", "year": 2025}

Implementation Reference

  • The main handler function implementing the logic for the 'upload_content' tool. It ensures the FileSearchStore exists, prepares upload arguments including metadata conversion, calls the Gemini client's uploadContent method, and returns a formatted MCPToolResponse.
    async execute(
      args: UploadContentArgs,
    ): Promise<MCPToolResponse<UploadContentResult>> {
      const { geminiClient, storeDisplayName } = this.context;
    
      // Ensure store exists
      const store = await geminiClient.ensureStore(storeDisplayName);
    
      // Upload content
      const uploadArgs: {
        storeName: string;
        content: string;
        displayName: string;
        metadata?: CustomMetadata[];
      } = {
        storeName: store.name,
        content: args.content,
        displayName: args.displayName,
      };
    
      if (args.metadata) {
        uploadArgs.metadata = convertMetadataInput(args.metadata);
      }
    
      const result = await geminiClient.uploadContent(uploadArgs);
    
      return {
        success: true,
        message: `Content uploaded successfully: ${args.displayName}`,
        data: {
          documentName: result.documentName,
          displayName: args.displayName,
          storeName: store.name,
          contentLength: args.content.length,
        },
      };
    }
  • Type definitions for input (UploadContentArgs) and output (UploadContentResult), tool name and description, and Zod-based input schema validation provided by getInputSchema().
    type UploadContentArgs = {
      content: string;
      displayName: string;
      metadata?: MetadataInput;
    };
    
    type UploadContentResult = {
      documentName: string;
      displayName: string;
      storeName: string;
      contentLength: number;
    };
    
    export class UploadContentTool extends BaseTool<UploadContentArgs> {
      readonly name = "upload_content";
      readonly description =
        "Upload text content to the FileSearchStore for RAG indexing. The content will be processed and made searchable.";
    
      getInputSchema() {
        return z.object({
          content: z
            .string()
            .min(1)
            .describe("Text content to upload to the knowledge base"),
          displayName: z
            .string()
            .min(1)
            .describe("Display name for the content in the store"),
          metadata: z
            .record(z.union([z.string(), z.number()]))
            .optional()
            .describe(
              "Custom metadata as key-value pairs. Values can be strings or numbers. Maximum 20 entries per document. Example: {\"category\": \"guide\", \"year\": 2025}",
            ),
        });
      }
  • The setupToolHandlers method registers all tools, including 'upload_content', with the MCP server using the tool's name, description, input schema, and bound handler.
    setupToolHandlers(): void {
      for (const tool of this.toolInstances.values()) {
        // Pass Zod schema directly to MCP SDK
        // SDK handles JSON Schema conversion internally for both stdio and HTTP transports
        this.server.registerTool(
          tool.name,
          {
            description: tool.description,
            inputSchema: tool.getInputSchema().shape,
          },
          tool.handler.bind(tool) as never,
        );
        this.registeredTools.push(tool.name);
      }
  • The initialize method creates instances of tools including new UploadContentTool(context) and stores them in the registry for later registration.
    initialize(context: ToolContext): void {
      // Manual tool registration for safety and explicit review
      const tools: Tool[] = [
        new UploadFileTool(context),
        new UploadContentTool(context),
        new QueryTool(context),
      ];
    
      for (const tool of tools) {
        this.toolInstances.set(tool.name, tool);
      }
    
      console.log(`✅ ToolRegistry initialized with ${String(this.toolInstances.size)} tools`);
  • Supporting helper method in GeminiClient that converts text content to a Blob and uploads it to the FileSearchStore using the shared uploadBlob logic. Called directly from the tool handler.
    async uploadContent(args: {
      storeName: string;
      content: string;
      displayName: string;
      metadata?: CustomMetadata[];
    }): Promise<UploadFileResult> {
      const encoder = new TextEncoder();
      const contentBytes = encoder.encode(args.content);
      const blob = new Blob([contentBytes], { type: "text/plain" });
    
      const uploadArgs: {
        storeName: string;
        blob: Blob;
        mimeType: string;
        displayName: string;
        metadata?: CustomMetadata[];
      } = {
        storeName: args.storeName,
        blob,
        mimeType: "text/plain",
        displayName: args.displayName,
      };
    
      if (args.metadata) {
        uploadArgs.metadata = args.metadata;
      }
    
      return await this.uploadBlob(uploadArgs);
    }
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 mentions processing and making content searchable but lacks details about permissions, rate limits, idempotency, error conditions, or what 'processed' entails. For a write operation with zero annotation coverage, this is inadequate.

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 two sentences that directly communicate the core functionality. Every word earns its place, and the information is front-loaded with no wasted verbiage.

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?

For a write operation with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after upload (e.g., success indicators, returned IDs, error responses), nor does it provide behavioral context needed for safe and effective use.

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%, providing good documentation for all parameters. The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('upload text content') and destination ('to the FileSearchStore for RAG indexing'), with a specific purpose ('made searchable'). It distinguishes from 'upload_file' by specifying text content rather than files, but doesn't explicitly contrast with 'query'.

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 'upload_file' or 'query'. It mentions the tool's purpose but offers no context about prerequisites, appropriate scenarios, or exclusion criteria.

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/masseater/gemini-rag-mcp'

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