Skip to main content
Glama

list_mcp_tools_by_server

Discover available tools for a specific MCP server to enable integration with the Letta system. Filter, paginate, and identify tools for adding to your workflow.

Instructions

List all available tools for a specific MCP server. Use list_mcp_servers first to see available servers, then add_mcp_tool_to_letta to import tools into Letta.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mcp_server_nameYesThe name of the MCP server to list tools for
filterNoOptional filter to search for specific tools by name or description
pageNoPage number for pagination (starts at 1)
pageSizeNoNumber of tools per page (1-100, default: 10)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolsYes
totalNo
server_nameYes

Implementation Reference

  • Core handler function that validates input, calls the MCP server API to list tools, applies filtering and pagination, formats the response, and handles errors.
    export async function handleListMcpToolsByServer(server, args) {
        if (!args?.mcp_server_name) {
            throw new Error('Missing required argument: mcp_server_name');
        }
    
        try {
            const serverName = encodeURIComponent(args.mcp_server_name);
            // Construct the relative API path
            const api_path = `/tools/mcp/servers/${serverName}/tools`;
    
            // Get headers using the server's built-in method
            const headers = server.getApiHeaders();
    
            // Use the server's configured api instance and get method
            const response = await server.api.get(api_path, {
                headers,
                timeout: 60000, // Keep the increased timeout
            });
    
            let tools = response.data; // Assuming response.data is an array of MCPTool objects
    
            // Apply filtering if provided
            if (args?.filter) {
                const filterLower = args.filter.toLowerCase();
                tools = tools.filter(
                    (tool) =>
                        (tool.name && tool.name.toLowerCase().includes(filterLower)) ||
                        (tool.description && tool.description.toLowerCase().includes(filterLower)),
                );
            }
    
            // Apply pagination
            const page = args?.page || 1;
            const pageSize = args?.pageSize || 10;
            const startIndex = (page - 1) * pageSize;
            const endIndex = startIndex + pageSize;
            const totalTools = tools.length;
            const totalPages = Math.ceil(totalTools / pageSize);
            const paginatedTools = tools.slice(startIndex, endIndex);
    
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            mcp_server_name: args.mcp_server_name,
                            pagination: {
                                page,
                                pageSize,
                                totalTools,
                                totalPages,
                                hasNextPage: page < totalPages,
                                hasPreviousPage: page > 1,
                            },
                            tool_count: paginatedTools.length,
                            tools: paginatedTools,
                        }),
                    },
                ],
            };
        } catch (error) {
            logger.error('Full error:', error.message); // Log message only to avoid circular refs
            // Handle potential 404 if server name not found, or other API errors
            if (error.response && error.response.status === 404) {
                throw new Error(`MCP Server not found: ${args.mcp_server_name}`);
            }
            // Safely extract error details without circular references
            let errorDetails = '';
            try {
                if (error.response?.data) {
                    errorDetails = JSON.stringify(error.response.data);
                }
            } catch {
                errorDetails = String(error.response?.data || '');
            }
            throw new Error(
                `Error executing list_mcp_tools_by_server: ${error.message}${errorDetails ? `\nResponse: ${errorDetails}` : ''}`,
            );
        }
    }
  • Tool definition object with name, description, and inputSchema for parameter validation.
    export const listMcpToolsByServerDefinition = {
        name: 'list_mcp_tools_by_server',
        description:
            'List all available tools for a specific MCP server. Use list_mcp_servers first to see available servers, then add_mcp_tool_to_letta to import tools into Letta.',
        inputSchema: {
            type: 'object',
            properties: {
                mcp_server_name: {
                    type: 'string',
                    description: 'The name of the MCP server to list tools for',
                },
                filter: {
                    type: 'string',
                    description: 'Optional filter to search for specific tools by name or description',
                },
                page: {
                    type: 'number',
                    description: 'Page number for pagination (starts at 1)',
                },
                pageSize: {
                    type: 'number',
                    description: 'Number of tools per page (1-100, default: 10)',
                },
            },
            required: ['mcp_server_name'], // mcp_server_name is now required
        },
    };
  • Handler dispatch in the central MCP tool call router (CallToolRequestSchema). Maps tool name to the handler function.
    case 'list_mcp_tools_by_server':
        return handleListMcpToolsByServer(server, request.params.arguments);
  • Registers the list of tools including list_mcp_tools_by_server via setRequestHandler for ListToolsRequestSchema. The definition is included in allTools array and enhanced.
    server.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: enhancedTools,
    }));
  • Imports the handler and definition from the implementation file for use in registration.
    import {
        handleListMcpToolsByServer,
        listMcpToolsByServerDefinition,
    } from './mcp/list-mcp-tools-by-server.js';
Behavior3/5

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

The description adds useful context about the workflow (prerequisite and next step), but doesn't disclose behavioral traits beyond what annotations might imply. Since annotations only provide a title ('List Server Tools'), the description carries more burden but still lacks details about pagination behavior, rate limits, or error conditions. It doesn't contradict annotations, but could provide more operational context.

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 perfectly concise with two sentences that each serve a clear purpose: the first states the tool's function, the second provides workflow guidance. There's zero wasted language, and the most important information (what the tool does) comes first.

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 there's an output schema (which handles return values) and 100% schema coverage for inputs, the description provides good contextual completeness for a listing tool. It explains the tool's role in the broader workflow and when to use it. The main gap is lack of behavioral details about pagination or filtering behavior, but the output schema likely covers the response structure.

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 fully documents all 4 parameters. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional semantic context about how parameters interact or practical usage examples.

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 verb ('List') and resource ('all available tools for a specific MCP server'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_agent_tools' or 'list_tools' (if they exist), which would require more specific scope clarification.

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

Usage Guidelines5/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 ('Use list_mcp_servers first to see available servers') and what to do after ('then add_mcp_tool_to_letta to import tools into Letta'). It clearly establishes prerequisites and next steps, helping the agent understand the workflow context.

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