Skip to main content
Glama

upload_tool

Upload custom tools to the Letta system for use with agents. Add tools to agents after creation and verify attachments.

Instructions

Upload a new tool to the Letta system. Use with attach_tool to add it to agents, or list_agent_tools to verify attachment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the tool
descriptionYesDescription of what the tool does
source_codeYesPython source code for the tool
categoryNoCategory/tag for the tool (e.g., "plane_api", "utility")custom
agent_idNoOptional agent ID to attach the tool to after creation

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
tool_idYes
categoryNo
attached_to_agentNo

Implementation Reference

  • The handleUploadTool function implements the core logic of the upload_tool: validates inputs, deletes existing tool if present, creates a new tool via API, optionally attaches to an agent, and returns JSON with tool details.
    export async function handleUploadTool(server, args) {
        try {
            // Validate arguments
            if (!args.name || typeof args.name !== 'string') {
                throw new Error('Missing required argument: name (must be a string)');
            }
            if (!args.description || typeof args.description !== 'string') {
                throw new Error('Missing required argument: description (must be a string)');
            }
            if (!args.source_code || typeof args.source_code !== 'string') {
                throw new Error('Missing required argument: source_code (must be a string)');
            }
    
            // Headers for API requests
            const headers = server.getApiHeaders();
    
            // If agent_id is provided, set the user_id header
            if (args.agent_id) {
                headers['user_id'] = args.agent_id;
            }
    
            // Prepare category/tag
            const category = args.category || 'custom';
    
            // Check if tool exists and delete if found
            const toolsResponse = await server.api.get('/tools/', { headers });
            const existingTools = toolsResponse.data;
            let existingToolId = null;
    
            for (const tool of existingTools) {
                if (tool.name === args.name) {
                    existingToolId = tool.id;
                    logger.info(
                        `Found existing tool ${args.name} with ID ${existingToolId}, will delete it first...`,
                    );
                    break;
                }
            }
    
            if (existingToolId) {
                try {
                    await server.api.delete(`/tools/${existingToolId}`, { headers });
                    logger.info(`Successfully deleted existing tool ${args.name}`);
                } catch (deleteError) {
                    logger.info(
                        `Failed to delete existing tool: ${deleteError}. Will try to continue anyway.`,
                    );
                }
            }
    
            // Prepare tool data
            const toolData = {
                source_code: args.source_code,
                description: args.description,
                tags: [category],
                source_type: 'python',
            };
    
            // Create the tool
            logger.info(`Creating tool "${args.name}"...`);
            const createResponse = await server.api.post('/tools/', toolData, { headers });
            const toolId = createResponse.data.id;
    
            // If agent_id is provided, attach the tool to the agent
            if (args.agent_id) {
                // Attach tool to agent
                const attachUrl = `/agents/${args.agent_id}/tools/attach/${toolId}`;
                await server.api.patch(attachUrl, {}, { headers });
    
                // Get agent info
                const agentInfoResponse = await server.api.get(`/agents/${args.agent_id}`, { headers });
                const agentName = agentInfoResponse.data.name || 'Unknown';
    
                return {
                    content: [
                        {
                            type: 'text',
                            text: JSON.stringify({
                                tool_id: toolId,
                                tool_name: args.name,
                                agent_id: args.agent_id,
                                agent_name: agentName,
                                category: category,
                            }),
                        },
                    ],
                };
            } else {
                // Just return the created tool info
                return {
                    content: [
                        {
                            type: 'text',
                            text: JSON.stringify({
                                tool_id: toolId,
                                tool_name: args.name,
                                category: category,
                            }),
                        },
                    ],
                };
            }
        } catch (error) {
            server.createErrorResponse(error);
        }
    }
  • Defines the tool schema including name, description, inputSchema with properties for name, description, source_code (required), optional category and agent_id.
    export const uploadToolToolDefinition = {
        name: 'upload_tool',
        description:
            'Upload a new tool to the Letta system. Use with attach_tool to add it to agents, or list_agent_tools to verify attachment.',
        inputSchema: {
            type: 'object',
            properties: {
                name: {
                    type: 'string',
                    description: 'Name of the tool',
                },
                description: {
                    type: 'string',
                    description: 'Description of what the tool does',
                },
                source_code: {
                    type: 'string',
                    description: 'Python source code for the tool',
                },
                category: {
                    type: 'string',
                    description: 'Category/tag for the tool (e.g., "plane_api", "utility")',
                    default: 'custom',
                },
                agent_id: {
                    type: 'string',
                    description: 'Optional agent ID to attach the tool to after creation',
                },
            },
            required: ['name', 'description', 'source_code'],
        },
    };
  • Registers the upload_tool in the MCP CallToolRequestSchema handler switch statement, dispatching calls to handleUploadTool.
    case 'upload_tool':
        return handleUploadTool(server, request.params.arguments);
  • Imports the handleUploadTool function and uploadToolToolDefinition from upload-tool.js.
    import { handleUploadTool, uploadToolToolDefinition } from './tools/upload-tool.js';
  • Includes uploadToolToolDefinition in the allTools array used for ListToolsRequestSchema and enhanced tool registration.
    uploadToolToolDefinition,
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds some behavioral context beyond the minimal annotations (which only provide a title). It mentions the relationship with other tools (attach_tool, list_agent_tools) which helps understand workflow. However, it doesn't disclose important behavioral traits like whether this is a mutating operation, what permissions are needed, or what happens on success/failure. With no annotations covering these aspects, the description carries more burden but provides only moderate transparency.

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 just two sentences that each serve a clear purpose. The first sentence states the core functionality, and the second provides usage guidance. There's zero wasted text, and the information is front-loaded appropriately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that this is a mutating tool (upload/creation) with no annotations covering safety or behavior, and with an output schema present (so return values are documented elsewhere), the description provides reasonable context. It covers the core purpose and usage workflow, though it could be more complete by addressing permissions, side effects, or error conditions that aren't covered by annotations.

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?

With 100% schema description coverage, the input schema already documents all 5 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter info in the description.

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') and resource ('a new tool to the Letta system'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'add_mcp_tool_to_letta' or 'attach_tool', which appear to have related functionality in the same domain.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool by mentioning two specific follow-up actions ('Use with attach_tool to add it to agents' and 'list_agent_tools to verify attachment'). This gives clear context for usage, though it doesn't explicitly state when NOT to use it or mention alternatives like 'add_mcp_tool_to_letta'.

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/oculairmedia/Letta-MCP-server'

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