Skip to main content
Glama

add_resource

Enables users to attach resources like files or URLs to tasks, providing essential context or supporting materials for task execution within the Divide and Conquer MCP Server framework.

Instructions

Adds a resource to the task.

Input Schema

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

Implementation Reference

  • The handler function for the 'add_resource' tool. Validates input parameters (name and url required), reads current task data, initializes resources array if needed, appends the new resource, persists changes to the config file via writeTaskData, and returns a success message 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: required 'name' and 'url' strings, optional 'description' 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 ListToolsRequestSchema response, providing 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)
    Route in the CallToolRequestSchema switch statement that dispatches 'add_resource' tool calls to the addResource handler method.
    case 'add_resource': return await this.addResource(request.params.arguments);
  • TypeScript interface defining the structure of a TaskResource, matching the tool's input schema and used in the TaskData.resources array.
    interface TaskResource { name: string; url: string; description?: string; }

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

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