Skip to main content
Glama

Letta Agents MCP Server

by elijahdev0
server.ts91.9 kB
#!/usr/bin/env node import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import axios, { AxiosRequestConfig, AxiosError } from "axios"; import { config as dotenvConfig } from "dotenv"; import { ListToolsRequestSchema, CallToolRequestSchema, Tool, JsonSchema, } from "@modelcontextprotocol/sdk/types.js"; // Load environment variables dotenvConfig(); // Define tool and security scheme types interface OpenApiTool extends Tool { method: string; path: string; security: any[]; } interface SecurityScheme { type: string; name?: string; in?: string; scheme?: string; } // Define tool schemas const TOOLS: OpenApiTool[] = [ { "id": "DELETE-v1-tools-tool-id", "name": "delete_tool", "description": "Delete a tool by name", "method": "DELETE", "path": "/v1/tools/{tool_id}", "inputSchema": { "type": "object", "properties": { "tool_id": { "type": "string", "description": "tool_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "tool_id" ] }, "security": [] }, { "id": "GET-v1-tools-tool-id", "name": "retrieve_tool", "description": "Get a tool by ID", "method": "GET", "path": "/v1/tools/{tool_id}", "inputSchema": { "type": "object", "properties": { "tool_id": { "type": "string", "description": "tool_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "tool_id" ] }, "security": [] }, { "id": "PATCH-v1-tools-tool-id", "name": "modify_tool", "description": "Update an existing tool", "method": "PATCH", "path": "/v1/tools/{tool_id}", "inputSchema": { "type": "object", "properties": { "tool_id": { "type": "string", "description": "tool_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "tool_id" ] }, "security": [] }, { "id": "GET-v1-tools-", "name": "list_tools", "description": "Get a list of all tools available to agents belonging to the org of the user", "method": "GET", "path": "/v1/tools/", "inputSchema": { "type": "object", "properties": { "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" }, "name": { "type": "string", "description": "name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-tools-", "name": "create_tool", "description": "Create a new tool", "method": "POST", "path": "/v1/tools/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "PUT-v1-tools-", "name": "upsert_tool", "description": "Create or update a tool", "method": "PUT", "path": "/v1/tools/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-tools-add-base-tools", "name": "add_base_tools", "description": "Upsert base tools", "method": "POST", "path": "/v1/tools/add-base-tools", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-tools-run", "name": "run_tool_from_source", "description": "Attempt to build a tool from source, then run it on the provided arguments", "method": "POST", "path": "/v1/tools/run", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-tools-composio-apps", "name": "list_composio_apps", "description": "Get a list of all Composio apps", "method": "GET", "path": "/v1/tools/composio/apps", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-tools-composio-apps-composio-app-name-actions", "name": "list_composio_actions_by_app", "description": "Get a list of all Composio actions for a specific app", "method": "GET", "path": "/v1/tools/composio/apps/{composio_app_name}/actions", "inputSchema": { "type": "object", "properties": { "composio_app_name": { "type": "string", "description": "composio_app_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "composio_app_name" ] }, "security": [] }, { "id": "POST-v1-tools-composio-composio-action-name", "name": "add_composio_tool", "description": "Add a new Composio tool by action name (Composio refers to each tool as an `Action`)", "method": "POST", "path": "/v1/tools/composio/{composio_action_name}", "inputSchema": { "type": "object", "properties": { "composio_action_name": { "type": "string", "description": "composio_action_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "composio_action_name" ] }, "security": [] }, { "id": "GET-v1-tools-mcp-servers", "name": "list_mcp_servers", "description": "Get a list of all configured MCP servers", "method": "GET", "path": "/v1/tools/mcp/servers", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "PUT-v1-tools-mcp-servers", "name": "add_mcp_server", "description": "Add a new MCP server to the Letta MCP server config", "method": "PUT", "path": "/v1/tools/mcp/servers", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-tools-mcp-servers-mcp-server-name-tools", "name": "list_mcp_tools_by_server", "description": "Get a list of all tools for a specific MCP server", "method": "GET", "path": "/v1/tools/mcp/servers/{mcp_server_name}/tools", "inputSchema": { "type": "object", "properties": { "mcp_server_name": { "type": "string", "description": "mcp_server_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "mcp_server_name" ] }, "security": [] }, { "id": "POST-v1-tools-mcp-servers-mcp-server-name-mcp-tool-name", "name": "add_mcp_tool", "description": "Register a new MCP tool as a Letta server by MCP server + tool name", "method": "POST", "path": "/v1/tools/mcp/servers/{mcp_server_name}/{mcp_tool_name}", "inputSchema": { "type": "object", "properties": { "mcp_server_name": { "type": "string", "description": "mcp_server_name parameter" }, "mcp_tool_name": { "type": "string", "description": "mcp_tool_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "mcp_server_name", "mcp_tool_name" ] }, "security": [] }, { "id": "DELETE-v1-tools-mcp-servers-mcp-server-name", "name": "delete_mcp_server", "description": "Add a new MCP server to the Letta MCP server config", "method": "DELETE", "path": "/v1/tools/mcp/servers/{mcp_server_name}", "inputSchema": { "type": "object", "properties": { "mcp_server_name": { "type": "string", "description": "mcp_server_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "mcp_server_name" ] }, "security": [] }, { "id": "GET-v1-sources-source-id", "name": "retrieve_source", "description": "Get all sources", "method": "GET", "path": "/v1/sources/{source_id}", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "PATCH-v1-sources-source-id", "name": "modify_source", "description": "Update the name or documentation of an existing data source.", "method": "PATCH", "path": "/v1/sources/{source_id}", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "DELETE-v1-sources-source-id", "name": "delete_source", "description": "Delete a data source.", "method": "DELETE", "path": "/v1/sources/{source_id}", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "GET-v1-sources-name-source-name", "name": "get_source_id_by_name", "description": "Get a source by name", "method": "GET", "path": "/v1/sources/name/{source_name}", "inputSchema": { "type": "object", "properties": { "source_name": { "type": "string", "description": "source_name parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_name" ] }, "security": [] }, { "id": "GET-v1-sources-", "name": "list_sources", "description": "List all data sources created by a user.", "method": "GET", "path": "/v1/sources/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sources-", "name": "create_source", "description": "Create a new data source.", "method": "POST", "path": "/v1/sources/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sources-source-id-upload", "name": "upload_file_to_source", "description": "Upload a file to a data source.", "method": "POST", "path": "/v1/sources/{source_id}/upload", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "GET-v1-sources-source-id-passages", "name": "list_source_passages", "description": "List all passages associated with a data source.", "method": "GET", "path": "/v1/sources/{source_id}/passages", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "GET-v1-sources-source-id-files", "name": "list_source_files", "description": "List paginated files associated with a data source.", "method": "GET", "path": "/v1/sources/{source_id}/files", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "limit": { "type": "integer", "description": "Number of files to return" }, "after": { "type": "string", "description": "Pagination cursor to fetch the next set of results" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id" ] }, "security": [] }, { "id": "DELETE-v1-sources-source-id-file-id", "name": "delete_file_from_source", "description": "Delete a data source.", "method": "DELETE", "path": "/v1/sources/{source_id}/{file_id}", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "source_id parameter" }, "file_id": { "type": "string", "description": "file_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "source_id", "file_id" ] }, "security": [] }, { "id": "GET-v1-agents-", "name": "list_agents", "description": "List all agents associated with a given user.\n\nThis endpoint retrieves a list of all agents and their configurations\nassociated with the specified user ID.", "method": "GET", "path": "/v1/agents/", "inputSchema": { "type": "object", "properties": { "name": { "type": "string", "description": "Name of the agent" }, "tags": { "type": "string", "description": "List of tags to filter agents by" }, "match_all_tags": { "type": "boolean", "description": "If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed-in tags." }, "before": { "type": "string", "description": "Cursor for pagination" }, "after": { "type": "string", "description": "Cursor for pagination" }, "limit": { "type": "string", "description": "Limit for pagination" }, "query_text": { "type": "string", "description": "Search agents by name" }, "project_id": { "type": "string", "description": "Search agents by project ID" }, "template_id": { "type": "string", "description": "Search agents by template ID" }, "base_template_id": { "type": "string", "description": "Search agents by base template ID" }, "identity_id": { "type": "string", "description": "Search agents by identity ID" }, "identifier_keys": { "type": "string", "description": "Search agents by identifier keys" }, "include_relationships": { "type": "string", "description": "Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. If not provided, all relationships are loaded by default. Using this can optimize performance by reducing unnecessary joins." }, "ascending": { "type": "boolean", "description": "Whether to sort agents oldest to newest (True) or newest to oldest (False, default)" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-agents-", "name": "create_agent", "description": "Create a new agent with the specified configuration.", "method": "POST", "path": "/v1/agents/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" }, "X-Project": { "type": "string", "description": "X-Project parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-agents-agent-id-export", "name": "export_agent_serialized", "description": "Export the serialized JSON representation of an agent.", "method": "GET", "path": "/v1/agents/{agent_id}/export", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-agents-import", "name": "import_agent_serialized", "description": "Import a serialized agent file and recreate the agent in the system.", "method": "POST", "path": "/v1/agents/import", "inputSchema": { "type": "object", "properties": { "append_copy_suffix": { "type": "boolean", "description": "If set to True, appends \"_copy\" to the end of the agent name." }, "override_existing_tools": { "type": "boolean", "description": "If set to True, existing tools can get their source code overwritten by the uploaded tool definitions. Note that Letta core tools can never be updated externally." }, "project_id": { "type": "string", "description": "The project ID to associate the uploaded agent with." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-agents-agent-id-context", "name": "retrieve_agent_context_window", "description": "Retrieve the context window of a specific agent.", "method": "GET", "path": "/v1/agents/{agent_id}/context", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id", "name": "modify_agent", "description": "Update an existing agent", "method": "PATCH", "path": "/v1/agents/{agent_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id", "name": "retrieve_agent", "description": "Get the state of the agent.", "method": "GET", "path": "/v1/agents/{agent_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "DELETE-v1-agents-agent-id", "name": "delete_agent", "description": "Delete an agent.", "method": "DELETE", "path": "/v1/agents/{agent_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-tools", "name": "list_agent_tools", "description": "Get tools from an existing agent", "method": "GET", "path": "/v1/agents/{agent_id}/tools", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-tools-attach-tool-id", "name": "attach_tool", "description": "Attach a tool to an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/tools/attach/{tool_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "tool_id": { "type": "string", "description": "tool_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "tool_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-tools-detach-tool-id", "name": "detach_tool", "description": "Detach a tool from an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/tools/detach/{tool_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "tool_id": { "type": "string", "description": "tool_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "tool_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-sources-attach-source-id", "name": "attach_source_to_agent", "description": "Attach a source to an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/sources/attach/{source_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "source_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-sources-detach-source-id", "name": "detach_source_from_agent", "description": "Detach a source from an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/sources/detach/{source_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "source_id": { "type": "string", "description": "source_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "source_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-sources", "name": "list_agent_sources", "description": "Get the sources associated with an agent.", "method": "GET", "path": "/v1/agents/{agent_id}/sources", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-core-memory", "name": "retrieve_agent_memory", "description": "Retrieve the memory state of a specific agent.\nThis endpoint fetches the current memory state of the agent identified by the user ID and agent ID.", "method": "GET", "path": "/v1/agents/{agent_id}/core-memory", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-core-memory-blocks-block-label", "name": "retrieve_core_memory_block", "description": "Retrieve a core memory block from an agent.", "method": "GET", "path": "/v1/agents/{agent_id}/core-memory/blocks/{block_label}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "block_label": { "type": "string", "description": "block_label parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "block_label" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-core-memory-blocks-block-label", "name": "modify_core_memory_block", "description": "Updates a core memory block of an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/core-memory/blocks/{block_label}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "block_label": { "type": "string", "description": "block_label parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "block_label" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-core-memory-blocks", "name": "list_core_memory_blocks", "description": "Retrieve the core memory blocks of a specific agent.", "method": "GET", "path": "/v1/agents/{agent_id}/core-memory/blocks", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-core-memory-blocks-attach-block-id", "name": "attach_core_memory_block", "description": "Attach a core memoryblock to an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/core-memory/blocks/attach/{block_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "block_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-core-memory-blocks-detach-block-id", "name": "detach_core_memory_block", "description": "Detach a core memory block from an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/core-memory/blocks/detach/{block_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "block_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-archival-memory", "name": "list_passages", "description": "Retrieve the memories in an agent's archival memory store (paginated query).", "method": "GET", "path": "/v1/agents/{agent_id}/archival-memory", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "after": { "type": "string", "description": "Unique ID of the memory to start the query range at." }, "before": { "type": "string", "description": "Unique ID of the memory to end the query range at." }, "limit": { "type": "string", "description": "How many results to include in the response." }, "search": { "type": "string", "description": "Search passages by text" }, "ascending": { "type": "string", "description": "Whether to sort passages oldest to newest (True, default) or newest to oldest (False)" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-agents-agent-id-archival-memory", "name": "create_passage", "description": "Insert a memory into an agent's archival memory store.", "method": "POST", "path": "/v1/agents/{agent_id}/archival-memory", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-archival-memory-memory-id", "name": "modify_passage", "description": "Modify a memory in the agent's archival memory store.", "method": "PATCH", "path": "/v1/agents/{agent_id}/archival-memory/{memory_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "memory_id": { "type": "string", "description": "memory_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "memory_id" ] }, "security": [] }, { "id": "DELETE-v1-agents-agent-id-archival-memory-memory-id", "name": "delete_passage", "description": "Delete a memory from an agent's archival memory store.", "method": "DELETE", "path": "/v1/agents/{agent_id}/archival-memory/{memory_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "memory_id": { "type": "string", "description": "memory_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "memory_id" ] }, "security": [] }, { "id": "GET-v1-agents-agent-id-messages", "name": "list_messages", "description": "Retrieve message history for an agent.", "method": "GET", "path": "/v1/agents/{agent_id}/messages", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "after": { "type": "string", "description": "Message after which to retrieve the returned messages." }, "before": { "type": "string", "description": "Message before which to retrieve the returned messages." }, "limit": { "type": "integer", "description": "Maximum number of messages to retrieve." }, "use_assistant_message": { "type": "boolean", "description": "Whether to use assistant messages" }, "assistant_message_tool_name": { "type": "string", "description": "The name of the designated message tool." }, "assistant_message_tool_kwarg": { "type": "string", "description": "The name of the message argument." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-agents-agent-id-messages", "name": "send_message", "description": "Process a user message and return the agent's response.\nThis endpoint accepts a message from a user and processes it through the agent.", "method": "POST", "path": "/v1/agents/{agent_id}/messages", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-messages-message-id", "name": "modify_message", "description": "Update the details of a message associated with an agent.", "method": "PATCH", "path": "/v1/agents/{agent_id}/messages/{message_id}", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "message_id": { "type": "string", "description": "message_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id", "message_id" ] }, "security": [] }, { "id": "POST-v1-agents-agent-id-messages-stream", "name": "create_agent_message_stream", "description": "Process a user message and return the agent's response.\nThis endpoint accepts a message from a user and processes it through the agent.\nIt will stream the steps of the response always, and stream the tokens if 'stream_tokens' is set to True.", "method": "POST", "path": "/v1/agents/{agent_id}/messages/stream", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-agents-agent-id-messages-async", "name": "create_agent_message_async", "description": "Asynchronously process a user message and return a run object.\nThe actual processing happens in the background, and the status can be checked using the run ID.", "method": "POST", "path": "/v1/agents/{agent_id}/messages/async", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "PATCH-v1-agents-agent-id-reset-messages", "name": "reset_messages", "description": "Resets the messages for an agent", "method": "PATCH", "path": "/v1/agents/{agent_id}/reset-messages", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "add_default_initial_messages": { "type": "boolean", "description": "If true, adds the default initial messages after resetting." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-groups-", "name": "create_group", "description": "Create a new multi-agent group with the specified configuration.", "method": "POST", "path": "/v1/groups/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" }, "X-Project": { "type": "string", "description": "X-Project parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-groups-", "name": "list_groups", "description": "Fetch all multi-agent groups matching query.", "method": "GET", "path": "/v1/groups/", "inputSchema": { "type": "object", "properties": { "manager_type": { "type": "string", "description": "Search groups by manager type" }, "before": { "type": "string", "description": "Cursor for pagination" }, "after": { "type": "string", "description": "Cursor for pagination" }, "limit": { "type": "string", "description": "Limit for pagination" }, "project_id": { "type": "string", "description": "Search groups by project id" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "PUT-v1-groups-", "name": "upsert_group", "description": "Create a new multi-agent group with the specified configuration.", "method": "PUT", "path": "/v1/groups/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" }, "X-Project": { "type": "string", "description": "X-Project parameter" } }, "required": [] }, "security": [] }, { "id": "DELETE-v1-groups-group-id", "name": "delete_group", "description": "Delete a multi-agent group.", "method": "DELETE", "path": "/v1/groups/{group_id}", "inputSchema": { "type": "object", "properties": { "group_id": { "type": "string", "description": "group_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "group_id" ] }, "security": [] }, { "id": "POST-v1-groups-group-id-messages", "name": "send_group_message", "description": "Process a user message and return the group's response.\nThis endpoint accepts a message from a user and processes it through through agents in the group based on the specified pattern", "method": "POST", "path": "/v1/groups/{group_id}/messages", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-groups-group-id-messages", "name": "list_group_messages", "description": "Retrieve message history for an agent.", "method": "GET", "path": "/v1/groups/{group_id}/messages", "inputSchema": { "type": "object", "properties": { "group_id": { "type": "string", "description": "group_id parameter" }, "after": { "type": "string", "description": "Message after which to retrieve the returned messages." }, "before": { "type": "string", "description": "Message before which to retrieve the returned messages." }, "limit": { "type": "integer", "description": "Maximum number of messages to retrieve." }, "use_assistant_message": { "type": "boolean", "description": "Whether to use assistant messages" }, "assistant_message_tool_name": { "type": "string", "description": "The name of the designated message tool." }, "assistant_message_tool_kwarg": { "type": "string", "description": "The name of the message argument." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "group_id" ] }, "security": [] }, { "id": "POST-v1-groups-group-id-messages-stream", "name": "send_group_message_streaming", "description": "Process a user message and return the group's responses.\nThis endpoint accepts a message from a user and processes it through agents in the group based on the specified pattern.\nIt will stream the steps of the response always, and stream the tokens if 'stream_tokens' is set to True.", "method": "POST", "path": "/v1/groups/{group_id}/messages/stream", "inputSchema": { "type": "object", "properties": { "group_id": { "type": "string", "description": "group_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "group_id" ] }, "security": [] }, { "id": "GET-v1-identities-", "name": "list_identities", "description": "Get a list of all identities in the database", "method": "GET", "path": "/v1/identities/", "inputSchema": { "type": "object", "properties": { "name": { "type": "string", "description": "name parameter" }, "project_id": { "type": "string", "description": "project_id parameter" }, "identifier_key": { "type": "string", "description": "identifier_key parameter" }, "identity_type": { "type": "string", "description": "identity_type parameter" }, "before": { "type": "string", "description": "before parameter" }, "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-identities-", "name": "create_identity", "description": "Make a POST request to /v1/identities/", "method": "POST", "path": "/v1/identities/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" }, "X-Project": { "type": "string", "description": "X-Project parameter" } }, "required": [] }, "security": [] }, { "id": "PUT-v1-identities-", "name": "upsert_identity", "description": "Make a PUT request to /v1/identities/", "method": "PUT", "path": "/v1/identities/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" }, "X-Project": { "type": "string", "description": "X-Project parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-identities-identity-id", "name": "retrieve_identity", "description": "Make a GET request to /v1/identities/{identity_id}", "method": "GET", "path": "/v1/identities/{identity_id}", "inputSchema": { "type": "object", "properties": { "identity_id": { "type": "string", "description": "identity_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "identity_id" ] }, "security": [] }, { "id": "PATCH-v1-identities-identity-id", "name": "update_identity", "description": "Make a PATCH request to /v1/identities/{identity_id}", "method": "PATCH", "path": "/v1/identities/{identity_id}", "inputSchema": { "type": "object", "properties": { "identity_id": { "type": "string", "description": "identity_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "identity_id" ] }, "security": [] }, { "id": "DELETE-v1-identities-identity-id", "name": "delete_identity", "description": "Delete an identity by its identifier key", "method": "DELETE", "path": "/v1/identities/{identity_id}", "inputSchema": { "type": "object", "properties": { "identity_id": { "type": "string", "description": "identity_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "identity_id" ] }, "security": [] }, { "id": "GET-v1-models-", "name": "list_models", "description": "Make a GET request to /v1/models/", "method": "GET", "path": "/v1/models/", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "GET-v1-models-embedding", "name": "list_embedding_models", "description": "Make a GET request to /v1/models/embedding", "method": "GET", "path": "/v1/models/embedding", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "GET-v1-blocks-", "name": "list_blocks", "description": "Make a GET request to /v1/blocks/", "method": "GET", "path": "/v1/blocks/", "inputSchema": { "type": "object", "properties": { "label": { "type": "string", "description": "Labels to include (e.g. human, persona)" }, "templates_only": { "type": "boolean", "description": "Whether to include only templates" }, "name": { "type": "string", "description": "Name of the block" }, "identity_id": { "type": "string", "description": "Search agents by identifier id" }, "identifier_keys": { "type": "string", "description": "Search agents by identifier keys" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-blocks-", "name": "create_block", "description": "Make a POST request to /v1/blocks/", "method": "POST", "path": "/v1/blocks/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "PATCH-v1-blocks-block-id", "name": "modify_block", "description": "Make a PATCH request to /v1/blocks/{block_id}", "method": "PATCH", "path": "/v1/blocks/{block_id}", "inputSchema": { "type": "object", "properties": { "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "block_id" ] }, "security": [] }, { "id": "DELETE-v1-blocks-block-id", "name": "delete_block", "description": "Make a DELETE request to /v1/blocks/{block_id}", "method": "DELETE", "path": "/v1/blocks/{block_id}", "inputSchema": { "type": "object", "properties": { "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "block_id" ] }, "security": [] }, { "id": "GET-v1-blocks-block-id", "name": "retrieve_block", "description": "Make a GET request to /v1/blocks/{block_id}", "method": "GET", "path": "/v1/blocks/{block_id}", "inputSchema": { "type": "object", "properties": { "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "block_id" ] }, "security": [] }, { "id": "GET-v1-blocks-block-id-agents", "name": "list_agents_for_block", "description": "Retrieves all agents associated with the specified block.\nRaises a 404 if the block does not exist.", "method": "GET", "path": "/v1/blocks/{block_id}/agents", "inputSchema": { "type": "object", "properties": { "block_id": { "type": "string", "description": "block_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "block_id" ] }, "security": [] }, { "id": "GET-v1-jobs-", "name": "list_jobs", "description": "List all jobs.", "method": "GET", "path": "/v1/jobs/", "inputSchema": { "type": "object", "properties": { "source_id": { "type": "string", "description": "Only list jobs associated with the source." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-jobs-active", "name": "list_active_jobs", "description": "List all active jobs.", "method": "GET", "path": "/v1/jobs/active", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-jobs-job-id", "name": "retrieve_job", "description": "Get the status of a job.", "method": "GET", "path": "/v1/jobs/{job_id}", "inputSchema": { "type": "object", "properties": { "job_id": { "type": "string", "description": "job_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "job_id" ] }, "security": [] }, { "id": "DELETE-v1-jobs-job-id", "name": "delete_job", "description": "Delete a job by its job_id.", "method": "DELETE", "path": "/v1/jobs/{job_id}", "inputSchema": { "type": "object", "properties": { "job_id": { "type": "string", "description": "job_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "job_id" ] }, "security": [] }, { "id": "GET-v1-health-", "name": "health_check", "description": "Make a GET request to /v1/health/", "method": "GET", "path": "/v1/health/", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "POST-v1-sandbox-config-", "name": "create_sandbox_config_v1_sandbox_config__post", "description": "Make a POST request to /v1/sandbox-config/", "method": "POST", "path": "/v1/sandbox-config/", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-sandbox-config-", "name": "list_sandbox_configs_v1_sandbox_config__get", "description": "Make a GET request to /v1/sandbox-config/", "method": "GET", "path": "/v1/sandbox-config/", "inputSchema": { "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of results to return" }, "after": { "type": "string", "description": "Pagination cursor to fetch the next set of results" }, "sandbox_type": { "type": "string", "description": "Filter for this specific sandbox type" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sandbox-config-e2b-default", "name": "create_default_e2b_sandbox_config_v1_sandbox_config_e2b_default_post", "description": "Make a POST request to /v1/sandbox-config/e2b/default", "method": "POST", "path": "/v1/sandbox-config/e2b/default", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sandbox-config-local-default", "name": "create_default_local_sandbox_config_v1_sandbox_config_local_default_post", "description": "Make a POST request to /v1/sandbox-config/local/default", "method": "POST", "path": "/v1/sandbox-config/local/default", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sandbox-config-local", "name": "create_custom_local_sandbox_config_v1_sandbox_config_local_post", "description": "Create or update a custom LocalSandboxConfig, including pip_requirements.", "method": "POST", "path": "/v1/sandbox-config/local", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "PATCH-v1-sandbox-config-sandbox-config-id", "name": "update_sandbox_config_v1_sandbox_config__sandbox_config_id__patch", "description": "Make a PATCH request to /v1/sandbox-config/{sandbox_config_id}", "method": "PATCH", "path": "/v1/sandbox-config/{sandbox_config_id}", "inputSchema": { "type": "object", "properties": { "sandbox_config_id": { "type": "string", "description": "sandbox_config_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "sandbox_config_id" ] }, "security": [] }, { "id": "DELETE-v1-sandbox-config-sandbox-config-id", "name": "delete_sandbox_config_v1_sandbox_config__sandbox_config_id__delete", "description": "Make a DELETE request to /v1/sandbox-config/{sandbox_config_id}", "method": "DELETE", "path": "/v1/sandbox-config/{sandbox_config_id}", "inputSchema": { "type": "object", "properties": { "sandbox_config_id": { "type": "string", "description": "sandbox_config_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "sandbox_config_id" ] }, "security": [] }, { "id": "POST-v1-sandbox-config-local-recreate-venv", "name": "force_recreate_local_sandbox_venv_v1_sandbox_config_local_recreate_venv_post", "description": "Forcefully recreate the virtual environment for the local sandbox.\nDeletes and recreates the venv, then reinstalls required dependencies.", "method": "POST", "path": "/v1/sandbox-config/local/recreate-venv", "inputSchema": { "type": "object", "properties": { "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-sandbox-config-sandbox-config-id-environment-variable", "name": "create_sandbox_env_var_v1_sandbox_config__sandbox_config_id__environment_variable_post", "description": "Make a POST request to /v1/sandbox-config/{sandbox_config_id}/environment-variable", "method": "POST", "path": "/v1/sandbox-config/{sandbox_config_id}/environment-variable", "inputSchema": { "type": "object", "properties": { "sandbox_config_id": { "type": "string", "description": "sandbox_config_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "sandbox_config_id" ] }, "security": [] }, { "id": "GET-v1-sandbox-config-sandbox-config-id-environment-variable", "name": "list_sandbox_env_vars_v1_sandbox_config__sandbox_config_id__environment_variable_get", "description": "Make a GET request to /v1/sandbox-config/{sandbox_config_id}/environment-variable", "method": "GET", "path": "/v1/sandbox-config/{sandbox_config_id}/environment-variable", "inputSchema": { "type": "object", "properties": { "sandbox_config_id": { "type": "string", "description": "sandbox_config_id parameter" }, "limit": { "type": "integer", "description": "Number of results to return" }, "after": { "type": "string", "description": "Pagination cursor to fetch the next set of results" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "sandbox_config_id" ] }, "security": [] }, { "id": "PATCH-v1-sandbox-config-environment-variable-env-var-id", "name": "update_sandbox_env_var_v1_sandbox_config_environment_variable__env_var_id__patch", "description": "Make a PATCH request to /v1/sandbox-config/environment-variable/{env_var_id}", "method": "PATCH", "path": "/v1/sandbox-config/environment-variable/{env_var_id}", "inputSchema": { "type": "object", "properties": { "env_var_id": { "type": "string", "description": "env_var_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "env_var_id" ] }, "security": [] }, { "id": "DELETE-v1-sandbox-config-environment-variable-env-var-id", "name": "delete_sandbox_env_var_v1_sandbox_config_environment_variable__env_var_id__delete", "description": "Make a DELETE request to /v1/sandbox-config/environment-variable/{env_var_id}", "method": "DELETE", "path": "/v1/sandbox-config/environment-variable/{env_var_id}", "inputSchema": { "type": "object", "properties": { "env_var_id": { "type": "string", "description": "env_var_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "env_var_id" ] }, "security": [] }, { "id": "GET-v1-providers-", "name": "list_providers", "description": "Get a list of all custom providers in the database", "method": "GET", "path": "/v1/providers/", "inputSchema": { "type": "object", "properties": { "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-providers-", "name": "create_provider", "description": "Create a new custom provider", "method": "POST", "path": "/v1/providers/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "PATCH-v1-providers-", "name": "modify_provider", "description": "Update an existing custom provider", "method": "PATCH", "path": "/v1/providers/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "DELETE-v1-providers-", "name": "delete_provider", "description": "Delete an existing custom provider", "method": "DELETE", "path": "/v1/providers/", "inputSchema": { "type": "object", "properties": { "provider_id": { "type": "string", "description": "The provider_id key to be deleted." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "provider_id" ] }, "security": [] }, { "id": "GET-v1-runs-", "name": "list_runs", "description": "List all runs.", "method": "GET", "path": "/v1/runs/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-runs-active", "name": "list_active_runs", "description": "List all active runs.", "method": "GET", "path": "/v1/runs/active", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-runs-run-id", "name": "retrieve_run", "description": "Get the status of a run.", "method": "GET", "path": "/v1/runs/{run_id}", "inputSchema": { "type": "object", "properties": { "run_id": { "type": "string", "description": "run_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "run_id" ] }, "security": [] }, { "id": "DELETE-v1-runs-run-id", "name": "delete_run", "description": "Delete a run by its run_id.", "method": "DELETE", "path": "/v1/runs/{run_id}", "inputSchema": { "type": "object", "properties": { "run_id": { "type": "string", "description": "run_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "run_id" ] }, "security": [] }, { "id": "GET-v1-runs-run-id-messages", "name": "list_run_messages", "description": "Get messages associated with a run with filtering options.\n\nArgs:\n run_id: ID of the run\n before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n limit: Maximum number of messages to return\n order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.\n role: Filter by role (user/assistant/system/tool)\n return_message_object: Whether to return Message objects or LettaMessage objects\n user_id: ID of the user making the request\n\nReturns:\n A list of messages associated with the run. Default is List[LettaMessage].", "method": "GET", "path": "/v1/runs/{run_id}/messages", "inputSchema": { "type": "object", "properties": { "run_id": { "type": "string", "description": "run_id parameter" }, "before": { "type": "string", "description": "Cursor for pagination" }, "after": { "type": "string", "description": "Cursor for pagination" }, "limit": { "type": "string", "description": "Maximum number of messages to return" }, "order": { "type": "string", "description": "Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order." }, "role": { "type": "string", "description": "Filter by role" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "run_id" ] }, "security": [] }, { "id": "GET-v1-runs-run-id-usage", "name": "retrieve_run_usage", "description": "Get usage statistics for a run.", "method": "GET", "path": "/v1/runs/{run_id}/usage", "inputSchema": { "type": "object", "properties": { "run_id": { "type": "string", "description": "run_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "run_id" ] }, "security": [] }, { "id": "GET-v1-runs-run-id-steps", "name": "list_run_steps", "description": "Get messages associated with a run with filtering options.\n\nArgs:\n run_id: ID of the run\n before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n limit: Maximum number of steps to return\n order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.\n\nReturns:\n A list of steps associated with the run.", "method": "GET", "path": "/v1/runs/{run_id}/steps", "inputSchema": { "type": "object", "properties": { "run_id": { "type": "string", "description": "run_id parameter" }, "before": { "type": "string", "description": "Cursor for pagination" }, "after": { "type": "string", "description": "Cursor for pagination" }, "limit": { "type": "string", "description": "Maximum number of messages to return" }, "order": { "type": "string", "description": "Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order." }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "run_id" ] }, "security": [] }, { "id": "GET-v1-steps", "name": "list_steps", "description": "List steps with optional pagination and date filters.\nDates should be provided in ISO 8601 format (e.g. 2025-01-29T15:01:19-08:00)", "method": "GET", "path": "/v1/steps", "inputSchema": { "type": "object", "properties": { "before": { "type": "string", "description": "Return steps before this step ID" }, "after": { "type": "string", "description": "Return steps after this step ID" }, "limit": { "type": "string", "description": "Maximum number of steps to return" }, "order": { "type": "string", "description": "Sort order (asc or desc)" }, "start_date": { "type": "string", "description": "Return steps after this ISO datetime (e.g. \"2025-01-29T15:01:19-08:00\")" }, "end_date": { "type": "string", "description": "Return steps before this ISO datetime (e.g. \"2025-01-29T15:01:19-08:00\")" }, "model": { "type": "string", "description": "Filter by the name of the model used for the step" }, "agent_id": { "type": "string", "description": "Filter by the ID of the agent that performed the step" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "GET-v1-steps-step-id", "name": "retrieve_step", "description": "Get a step by ID.", "method": "GET", "path": "/v1/steps/{step_id}", "inputSchema": { "type": "object", "properties": { "step_id": { "type": "string", "description": "step_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "step_id" ] }, "security": [] }, { "id": "PATCH-v1-steps-step-id-transaction-transaction-id", "name": "update_step_transaction_id", "description": "Update the transaction ID for a step.", "method": "PATCH", "path": "/v1/steps/{step_id}/transaction/{transaction_id}", "inputSchema": { "type": "object", "properties": { "step_id": { "type": "string", "description": "step_id parameter" }, "transaction_id": { "type": "string", "description": "transaction_id parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [ "step_id", "transaction_id" ] }, "security": [] }, { "id": "GET-v1-tags-", "name": "list_tags", "description": "Get a list of all tags in the database", "method": "GET", "path": "/v1/tags/", "inputSchema": { "type": "object", "properties": { "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" }, "query_text": { "type": "string", "description": "query_text parameter" }, "user_id": { "type": "string", "description": "user_id parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-voice-beta-agent-id-chat-completions", "name": "create_voice_chat_completions", "description": "Make a POST request to /v1/voice-beta/{agent_id}/chat/completions", "method": "POST", "path": "/v1/voice-beta/{agent_id}/chat/completions", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "GET-v1-admin-users-", "name": "list_users", "description": "Get a list of all users in the database", "method": "GET", "path": "/v1/admin/users/", "inputSchema": { "type": "object", "properties": { "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-admin-users-", "name": "create_user", "description": "Create a new user in the database", "method": "POST", "path": "/v1/admin/users/", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "PUT-v1-admin-users-", "name": "update_user", "description": "Update a user in the database", "method": "PUT", "path": "/v1/admin/users/", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "DELETE-v1-admin-users-", "name": "delete_user", "description": "Make a DELETE request to /v1/admin/users/", "method": "DELETE", "path": "/v1/admin/users/", "inputSchema": { "type": "object", "properties": { "user_id": { "type": "string", "description": "The user_id key to be deleted." } }, "required": [ "user_id" ] }, "security": [] }, { "id": "GET-v1-admin-orgs-", "name": "list_orgs", "description": "Get a list of all orgs in the database", "method": "GET", "path": "/v1/admin/orgs/", "inputSchema": { "type": "object", "properties": { "after": { "type": "string", "description": "after parameter" }, "limit": { "type": "string", "description": "limit parameter" } }, "required": [] }, "security": [] }, { "id": "POST-v1-admin-orgs-", "name": "create_organization", "description": "Create a new org in the database", "method": "POST", "path": "/v1/admin/orgs/", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] }, { "id": "DELETE-v1-admin-orgs-", "name": "delete_organization_by_id", "description": "Make a DELETE request to /v1/admin/orgs/", "method": "DELETE", "path": "/v1/admin/orgs/", "inputSchema": { "type": "object", "properties": { "org_id": { "type": "string", "description": "The org_id key to be deleted." } }, "required": [ "org_id" ] }, "security": [] }, { "id": "PATCH-v1-admin-orgs-", "name": "update_organization", "description": "Make a PATCH request to /v1/admin/orgs/", "method": "PATCH", "path": "/v1/admin/orgs/", "inputSchema": { "type": "object", "properties": { "org_id": { "type": "string", "description": "The org_id key to be updated." } }, "required": [ "org_id" ] }, "security": [] }, { "id": "POST-openai-v1-agent-id-chat-completions", "name": "create_chat_completions", "description": "Make a POST request to /openai/v1/{agent_id}/chat/completions", "method": "POST", "path": "/openai/v1/{agent_id}/chat/completions", "inputSchema": { "type": "object", "properties": { "agent_id": { "type": "string", "description": "agent_id parameter" }, "user-id": { "type": "string", "description": "user-id parameter" } }, "required": [ "agent_id" ] }, "security": [] }, { "id": "POST-v1-auth", "name": "authenticate_user_v1_auth_post", "description": "Authenticates the user and sends response with User related data.\n\nCurrently, this is a placeholder that simply returns a UUID placeholder", "method": "POST", "path": "/v1/auth", "inputSchema": { "type": "object", "properties": {}, "required": [] }, "security": [] } ]; const SECURITY_SCHEMES: Record<string, SecurityScheme> = {}; /** * MCP Server for Letta API * Generated from OpenAPI spec version 1.0.0 * Generated on 2025-03-27T22:37:17.521Z */ class MCPServer { private server: Server; private tools: Map<string, Tool> = new Map(); private debug: boolean; private baseUrl: string; private headers: Record<string, string>; constructor() { // Initialize properties this.debug = process.env.DEBUG === "true"; this.baseUrl = process.env.API_BASE_URL || ""; this.headers = this.parseHeaders(process.env.API_HEADERS || ""); // Initialize tools map - do this before creating server this.initializeTools(); // Create MCP server with correct capabilities this.server = new Server( { name: process.env.SERVER_NAME || "openapi-mcp-server", version: process.env.SERVER_VERSION || "1.0.0", }, { capabilities: { tools: true, // Enable tools capability }, } ); // Set up request handlers - don't log here this.setupHandlers(); } /** * Parse headers from string */ private parseHeaders(headerStr: string): Record<string, string> { const headers: Record<string, string> = {}; if (headerStr) { headerStr.split(",").forEach((header) => { const [key, value] = header.split(":"); if (key && value) headers[key.trim()] = value.trim(); }); } return headers; } /** * Initialize tools map from OpenAPI spec * This runs before the server is connected, so don't log here */ private initializeTools(): void { // Initialize each tool in the tools map for (const tool of TOOLS) { this.tools.set(tool.id, { name: tool.name, description: tool.description, inputSchema: tool.inputSchema as JsonSchema, // Don't include security at the tool level }); } // Don't log here, we're not connected yet console.error(`Initialized ${this.tools.size} tools`); } /** * Set up request handlers */ private setupHandlers(): void { // Handle tool listing requests this.server.setRequestHandler(ListToolsRequestSchema, async () => { this.log('debug', "Handling ListTools request"); // Return tools in the format expected by MCP SDK return { tools: Array.from(this.tools.entries()).map(([id, tool]) => ({ id, ...tool, })), }; }); // Handle tool execution requests this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { id, name, arguments: params } = request.params; this.log('debug', "Handling CallTool request", { id, name, params }); let toolId: string | undefined; let toolDetails: OpenApiTool | undefined; try { // Find the requested tool toolId = id; if (!toolId && name) { for (const [tid, tool] of this.tools.entries()) { if (tool.name === name) { toolId = tid; break; } } } if (!toolId) { throw new Error(`Tool not found: ${id || name}`); } toolDetails = TOOLS.find(t => t.id === toolId); if (!toolDetails) { throw new Error(`Tool details not found for ID: ${toolId}`); } this.log('info', `Executing tool: ${toolId}`); // Execute the API call const result = await this.executeApiCall(toolDetails, params || {}); // Return the result in correct MCP format return { content: [ { type: "application/json", data: result } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); this.log('error', `Error executing tool ${toolId || name}: ${errorMessage}`); // Format error according to MCP SDK expectations return { error: { message: errorMessage, details: error instanceof Error && 'response' in error ? JSON.stringify((error as any).response?.data) : undefined } }; } }); } /** * Execute an API call for a tool */ private async executeApiCall(tool: OpenApiTool, params: Record<string, any>): Promise<any> { // Get method and path from tool const method = tool.method; let path = tool.path; // Clone params to avoid modifying the original const requestParams = { ...params }; // Replace path parameters with values from params Object.entries(requestParams).forEach(([key, value]) => { const placeholder = `{${key}}`; if (path.includes(placeholder)) { path = path.replace(placeholder, encodeURIComponent(String(value))); delete requestParams[key]; // Remove used parameter } }); // Build the full URL const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl : `${this.baseUrl}/`; const cleanPath = path.startsWith("/") ? path.slice(1) : path; const url = new URL(cleanPath, baseUrl).toString(); this.log('debug', `API Request: ${method} ${url}`); try { // Configure the request const config: AxiosRequestConfig = { method: method.toLowerCase(), url, headers: { ...this.headers }, }; // Apply security headers based on tool security requirements if (tool.security && Array.isArray(tool.security)) { for (const requirement of tool.security) { for (const securitySchemeName of Object.keys(requirement)) { const securityDefinition = SECURITY_SCHEMES[securitySchemeName]; if (securityDefinition) { const authType = securityDefinition.type; // Handle API key if (authType === 'apiKey') { const apiKeyName = securityDefinition.name || ''; const envVarName = `${securitySchemeName.toUpperCase()}_${apiKeyName.toUpperCase()}`; const apiKeyValue = process.env[envVarName]; if (apiKeyValue) { if (securityDefinition.in === 'header') { config.headers = config.headers || {}; config.headers[apiKeyName] = apiKeyValue; } else if (securityDefinition.in === 'query') { config.params = config.params || {}; config.params[apiKeyName] = apiKeyValue; } } else { this.log('warning', `API Key environment variable not found: ${envVarName}`); } } // Handle bearer token else if (authType === 'http' && securityDefinition.scheme === 'bearer') { const envVarName = `${securitySchemeName.toUpperCase()}_BEARERTOKEN`; const bearerToken = process.env[envVarName]; if (bearerToken) { config.headers = config.headers || {}; config.headers['Authorization'] = `Bearer ${bearerToken}`; } else { this.log('warning', `Bearer Token environment variable not found: ${envVarName}`); } } // Handle basic auth else if (authType === 'http' && securityDefinition.scheme === 'basic') { const username = process.env[`${securitySchemeName.toUpperCase()}_USERNAME`]; const password = process.env[`${securitySchemeName.toUpperCase()}_PASSWORD`]; if (username && password) { const auth = Buffer.from(`${username}:${password}`).toString('base64'); config.headers = config.headers || {}; config.headers['Authorization'] = `Basic ${auth}`; } else { this.log('warning', `Basic auth credentials not found for ${securitySchemeName}`); } } } } } } // Add parameters based on request method if (["GET", "DELETE"].includes(method)) { // For GET/DELETE, send params as query string config.params = { ...(config.params || {}), ...requestParams }; } else { // For POST/PUT/PATCH, send params as JSON body config.data = requestParams; if (config.headers) { config.headers["Content-Type"] = "application/json"; } } this.log('debug', "Request config:", { url: config.url, method: config.method, params: config.params, headers: config.headers ? Object.keys(config.headers) : [] }); // Execute the request const response = await axios(config); this.log('debug', `Response status: ${response.status}`); return response.data; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); this.log('error', `API request failed: ${errorMessage}`); if (axios.isAxiosError(error)) { const axiosError = error as AxiosError; const responseData = axiosError.response?.data; const responseStatus = axiosError.response?.status; this.log('error', 'API Error Details:', { status: responseStatus, data: typeof responseData === 'object' ? JSON.stringify(responseData) : String(responseData) }); // Rethrow with more context for better error handling const detailedError = new Error(`API request failed with status ${responseStatus}: ${errorMessage}`); (detailedError as any).response = axiosError.response; throw detailedError; } throw error; } } /** * Log messages with appropriate level * Only sends to MCP if we're connected */ private log(level: 'debug' | 'info' | 'warning' | 'error', message: string, data?: any): void { // Always log to stderr for visibility console.error(`[${level.toUpperCase()}] ${message}${data ? ': ' + JSON.stringify(data) : ''}`); // Only try to send via MCP if we're in debug mode or it's important if (this.debug || level !== 'debug') { try { // Only send if server exists and is connected if (this.server && (this.server as any).isConnected) { this.server.sendLoggingMessage({ level, data: `[MCP Server] ${message}${data ? ': ' + JSON.stringify(data) : ''}` }); } } catch (e) { // If logging fails, log to stderr console.error('Failed to send log via MCP:', (e as Error).message); } } } /** * Start the server */ async start(): Promise<void> { try { // Create stdio transport const transport = new StdioServerTransport(); console.error("MCP Server starting on stdio transport"); // Connect to the transport await this.server.connect(transport); // Now we can safely log via MCP console.error(`Registered ${this.tools.size} tools`); this.log('info', `MCP Server started successfully with ${this.tools.size} tools`); } catch (error) { console.error("Failed to start MCP server:", error); process.exit(1); } } } // Start the server async function main(): Promise<void> { try { const server = new MCPServer(); await server.start(); } catch (error) { console.error("Failed to start server:", error); process.exit(1); } } main();

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/elijahdev0/mcp-server'

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