Skip to main content
Glama

configure_endpoint

Set up mock API endpoints with sequential responses for testing and development. Define HTTP methods, paths, and response sequences to simulate real API behavior.

Instructions

Configure a mock API endpoint with sequential responses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier
methodYesHTTP method (GET, POST, etc.)
pathYesEndpoint path (e.g., /api/users)
responsesYesArray of responses for sequential behavior

Implementation Reference

  • The handler implementation for the configure_endpoint tool. It validates the input arguments, retrieves or creates a session using the sessionManager, and updates the endpoints map for that session.
    configure_endpoint: async (args: any) => {
      try {
        const { sessionId, method, path, responses } = args;
    
        if (!sessionId || !method || !path) {
          return {
            success: false,
            error: 'Missing required fields: sessionId, method, path'
          };
        }
    
        if (!responses || !Array.isArray(responses) || responses.length === 0) {
          return {
            success: false,
            error: 'Must provide at least one response'
          };
        }
    
        const session = sessionManager.getOrCreate(sessionId);
        const key = `${method.toUpperCase()}:${path}`;
    
        session.endpoints.set(key, {
          method,
          path,
          responses,
          callCount: 0
        });
    
        return { success: true };
      } catch (error: any) {
        return {
          success: false,
          error: `Failed to configure endpoint: ${error.message}`
        };
      }
    },
  • The tool registration block for configure_endpoint, including the schema definition.
    {
      name: 'configure_endpoint',
      description: 'Configure a mock API endpoint with sequential responses',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'Session identifier',
          },
          method: {
            type: 'string',
            description: 'HTTP method (GET, POST, etc.)',
          },
          path: {
            type: 'string',
            description: 'Endpoint path (e.g., /api/users)',
          },
          responses: {
            type: 'array',
            description: 'Array of responses for sequential behavior',
            items: {
              type: 'object',
              properties: {
                status: { type: 'number' },
                headers: { type: 'object' },
                body: {},
              },
              required: ['status'],
            },
          },
        },
        required: ['sessionId', 'method', 'path', 'responses'],
      },
    },

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/aj-bartocci/SpyNet'

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