Skip to main content
Glama

add_resource

Add resources like files or URLs to tasks to provide context and reference materials for AI agents working on complex problem decomposition.

Instructions

Adds a resource to the task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the resource
urlYesURL or file path of the resource
descriptionNoDescription of the resource

Implementation Reference

  • The main handler function for the 'add_resource' tool. It validates input, reads current task data, appends the new resource to the resources array, persists the updated data to the config file, and returns success or error response.
    private async addResource(args: any): Promise<any> { if (!args?.name || !args?.url) { throw new McpError(ErrorCode.InvalidParams, 'Resource name and URL are required'); } try { const taskData = await this.readTaskData(); // Initialize the resources array if it doesn't exist if (!taskData.resources) { taskData.resources = []; } // Add the resource taskData.resources.push({ name: args.name, url: args.url, description: args.description || '' }); // Write the updated task data to the file await this.writeTaskData(taskData); return { content: [ { type: 'text', text: 'Resource added successfully.', }, ], }; } catch (error) { console.error('Error adding resource:', error); return { content: [ { type: 'text', text: `Error adding resource: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Input schema defining the parameters for the 'add_resource' tool: name (required string), url (required string), description (optional string).
    inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the resource' }, url: { type: 'string', description: 'URL or file path of the resource' }, description: { type: 'string', description: 'Description of the resource' } }, required: ['name', 'url']
  • src/index.ts:338-359 (registration)
    Registration of the 'add_resource' tool in the ListTools response, including name, description, and input schema.
    { name: 'add_resource', description: 'Adds a resource to the task.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the resource' }, url: { type: 'string', description: 'URL or file path of the resource' }, description: { type: 'string', description: 'Description of the resource' } }, required: ['name', 'url'] } },
  • src/index.ts:444-445 (registration)
    Dispatch/registration in the CallToolRequest handler switch statement that routes 'add_resource' calls to the addResource method.
    case 'add_resource': return await this.addResource(request.params.arguments);
  • TypeScript interface defining the structure of a TaskResource, used for resources in task data.
    name: string; url: string; description?: string; }

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/landicefu/divide-and-conquer-mcp-server'

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