Skip to main content
Glama

generate-backend-client

Create a TypeScript client for direct Kalendis API calls with x-api-key authentication. Generates code to manage users, availability, bookings, and scheduling operations.

Instructions

Generate a TypeScript client that calls Kalendis API directly with x-api-key authentication

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentNoTarget environment (optional, defaults to production)
typesImportPathNoImport path for types file (optional, defaults to "../types")

Implementation Reference

  • Core handler function that generates the complete TypeScript backend client code by combining base client class, request method, and individual API method implementations based on ENDPOINTS.
    export function generateBackendClient(options: GenerateOptions): string {
      const typesPath = options.typesImportPath || '../types';
      const baseClient = generateBaseClient(options.environment, typesPath);
    
      const methods = Object.entries(ENDPOINTS)
        .map(([name, endpoint]) => generateMethod(name, endpoint))
        .join('\n');
    
      return `${baseClient}
    ${methods}
    }
    
    export default KalendisClient;
    `;
    }
  • src/server.ts:35-53 (registration)
    Tool registration in the TOOLS array, including name, description, and input schema.
    {
      name: 'generate-backend-client',
      description: 'Generate a TypeScript client that calls Kalendis API directly with x-api-key authentication',
      inputSchema: {
        type: 'object',
        properties: {
          environment: {
            type: 'string',
            enum: ['production', 'staging', 'development'],
            description: 'Target environment (optional, defaults to production)',
          },
          typesImportPath: {
            type: 'string',
            description: 'Import path for types file (optional, defaults to "../types")',
          },
        },
        required: [],
      },
    },
  • MCP server handler case that validates input and calls the generateBackendClient function to produce the client code.
    case 'generate-backend-client': {
      const environment = args?.environment || 'production';
      if (typeof environment !== 'string' || !['production', 'staging', 'development'].includes(environment)) {
        throw new Error('Valid environment is required (production, staging, development)');
      }
    
      const code = generateBackendClient({
        environment: environment as Environment,
        typesImportPath: args?.typesImportPath as string | undefined,
        framework: 'vanilla', // Not used in backend client
      });
    
      return {
        content: [
          {
            type: 'text',
            text: code,
          },
        ],
      };
    }
  • Input schema definition for the tool, specifying optional environment and typesImportPath parameters.
    inputSchema: {
      type: 'object',
      properties: {
        environment: {
          type: 'string',
          enum: ['production', 'staging', 'development'],
          description: 'Target environment (optional, defaults to production)',
        },
        typesImportPath: {
          type: 'string',
          description: 'Import path for types file (optional, defaults to "../types")',
        },
      },
      required: [],
    },
  • Helper function that generates the base KalendisClient class with authentication and generic request method.
    function generateBaseClient(environment: Environment, typesPath: string): string {
      return `import * as Types from '${typesPath}';
    
    class KalendisClient {
      private readonly apiKey: string;
      private readonly baseUrl: string;
    
      constructor(options: { apiKey: string }) {
        if (!options.apiKey) {
          throw new Error('API key is required. Pass it in the constructor: new KalendisClient({ apiKey: "your-key" })');
        }
        this.apiKey = options.apiKey;
        this.baseUrl = process.env.KALENDIS_API_URL || 'https://sandbox.api.kalendis.dev';
      }
    
      private async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
        const url = \`\${this.baseUrl}\${endpoint}\`;
        
        try {
          const response = await fetch(url, {
            ...options,
            headers: {
              'x-api-key': this.apiKey,
              'Content-Type': 'application/json',
              ...options.headers
            }
          });
    
          if (!response.ok) {
            let errorMessage = \`Kalendis API Error (\${response.status}): \${response.statusText}\`;
            try {
              const error = await response.json();
              errorMessage = \`Kalendis API Error (\${response.status}): \${error.message || error.error || response.statusText}\`;
            } catch {
              // Use default error message if response isn't JSON
            }
            
            if (response.status === 401) {
              throw new Error('Authentication failed: Invalid or missing API key');
            } else if (response.status === 403) {
              throw new Error('Permission denied: Your API key does not have access to this resource');
            }
            
            throw new Error(errorMessage);
          }
    
          return response.json();
        } catch (error) {
          if (error instanceof TypeError && error.message.includes('fetch')) {
            throw new Error(\`Cannot connect to Kalendis API at \${this.baseUrl}. Please ensure the service is running.\`);
          }
          throw error;
        }
      }`;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions authentication but doesn't cover other important aspects like whether this is a read/write operation, what permissions are needed, what the output looks like (e.g., file generation), or any rate limits. The description is minimal and lacks behavioral 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 a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized and front-loaded with the core functionality.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool that generates code. It doesn't explain what the output is (e.g., a file, code snippet), how it's delivered, or any behavioral traits. The description alone is insufficient for understanding the tool's full behavior.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters with descriptions and enum values. The description doesn't add any parameter-specific information beyond what's in the schema, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Generate a TypeScript client'), the target ('Kalendis API'), and the authentication method ('x-api-key authentication'). It distinguishes from sibling tools like 'generate-api-routes' and 'generate-frontend-client' by specifying it's for backend/direct API calls.

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

Usage Guidelines3/5

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

The description implies usage for generating a TypeScript client with specific authentication, but doesn't explicitly state when to use this tool versus alternatives like 'generate-frontend-client' or 'generate-api-routes'. No explicit exclusions or prerequisites are mentioned.

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/kalendis-dev/kalendis-mcp'

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