Meta-Tool Specifications

This is the complete technical reference for Toolcog’s API meta-tools. These tools are exposed via the Model Context Protocol (MCP) and enable AI to discover, learn, and execute API operations.

Overview

ToolPurposeBehavior
find_apiDiscover operationsSemantic search, read-only
learn_apiLearn interfacesTypeScript generation, read-only
call_apiExecute operationsHTTP requests, may modify state

All tools return the same response structure:

interface ToolResult {
content: Array<{ type: "text"; text: string }>;
isError?: boolean;
}

find_api

Discovers API operations matching a natural language intent using semantic search.

Parameters

ParameterTypeRequiredDescription
intentstringYesWhat you want to accomplish

Input Schema

{
"type": "object",
"properties": {
"intent": {
"type": "string",
"description": "The behavior of the API operation you intend to perform"
}
},
"required": ["intent"]
}

Intent Guidelines

The intent should describe behavior, not entities:

Good IntentBad Intent
”create a new customer with email and payment info""stripe customer"
"list all repositories for a user""github repos"
"send a transactional email with template""sendgrid email”

Good intents:

Bad intents:

Success Response

Returns a markdown-formatted list of matching operations:

Found 3 API operation(s):
- stripe/customers.create — create a new customer with email and payment details
- stripe/customers.update — modify an existing customer's information
- braintree/customers.create — create a customer in the payment vault

Each result includes:

Results are ranked by semantic similarity. The top 10 matches are returned.

No Results Response

No API operations found matching your intent. Try rephrasing your search.

Error Response

{
content: [{ type: "text", text: "Missing intent parameter" }],
isError: true
}

Behavior Notes


learn_api

Retrieves TypeScript type declarations for an operation’s request and response interfaces.

Parameters

ParameterTypeRequiredDefaultDescription
operationstringYesOperation identifier
requestbooleanNotrueInclude request types
responsebooleanNofalseInclude response types

Input Schema

{
"type": "object",
"properties": {
"operation": {
"type": "string",
"description": "The API operation to learn about (format: serviceName/operationName)"
},
"request": {
"type": "boolean",
"description": "Include request types",
"default": true
},
"response": {
"type": "boolean",
"description": "Include response types",
"default": false
}
},
"required": ["operation"]
}

Operation Format

Operations must be specified as serviceName/operationName:

github/repos.create
stripe/customers.create
sendgrid/mail.send

Invalid formats return an error.

Success Response

Returns TypeScript type declarations:

interface CreateCustomerRequest {
email: string;
name?: string;
description?: string;
metadata?: Record<string, string>;
payment_method?: string;
address?: Address;
}
interface Address {
line1: string;
line2?: string;
city: string;
state?: string;
postal_code: string;
country: string;
}

The response includes:

Reference Resolution

Types are resolved to a depth of 2 indirections. Deep circular references are truncated with inline comments.

Error Responses

Invalid format:

Invalid operation format. Expected: serviceName/operationName

Operation not found:

Operation not found: stripe/invalid.operation

No types available:

No type information available for this operation.

Behavior Notes


call_api

Executes an API operation with the provided arguments.

Parameters

ParameterTypeRequiredDescription
operationstringYesOperation identifier
argumentsobjectYesArguments by location

Arguments Structure

interface Arguments {
path?: Record<string, unknown>; // Path parameters
query?: Record<string, unknown>; // Query string parameters
header?: Record<string, unknown>; // Request headers
body?: unknown; // Request body
server?: Record<string, unknown>; // Server URL variables
cookie?: Record<string, unknown>; // Cookie values
}

Input Schema

{
"type": "object",
"properties": {
"operation": {
"type": "string",
"description": "The API operation to call (format: serviceName/operationName)"
},
"arguments": {
"type": "object",
"properties": {
"path": {
"type": "object",
"description": "Path arguments"
},
"query": {
"type": "object",
"description": "Query arguments"
},
"header": {
"type": "object",
"description": "Header arguments"
},
"body": {
"description": "Body argument"
}
},
"required": []
}
},
"required": ["operation", "arguments"]
}

Example Call

{
"operation": "github/repos.create",
"arguments": {
"body": {
"name": "my-new-repo",
"description": "A repository created via Toolcog",
"private": true
}
}
}

Success Response

Returns the HTTP response:

{
"status": 201,
"statusText": "Created",
"body": {
"id": 123456789,
"name": "my-new-repo",
"full_name": "user/my-new-repo",
"private": true,
"html_url": "https://github.com/user/my-new-repo"
}
}

Response fields:

Error Responses

Missing operation:

Missing "operation" parameter

Missing arguments:

Missing "arguments" parameter

Invalid format:

Invalid operation format. Expected: serviceName/operationName

Operation not found:

Operation not found: stripe/invalid.operation

Authorization required:

When credentials are missing or insufficient, the response includes:

{
"status": 401,
"statusText": "Unauthorized",
"body": {
"error": "authorization_required",
"message": "This operation requires authorization",
"connect_url": "https://toolcog.com/connect?owner={owner}&bridge={bridge}&scope=repo"
}
}

The connect_url can be provided to the user to authorize the service.

Credential Resolution

Credentials are resolved automatically based on the operation’s security requirements:

Credential TypeSatisfies Schemes
OAuthoauth2, http:bearer
API KeyapiKey
HTTP Basichttp:basic
HTTP Bearerhttp:bearer

Credentials must match the scheme name declared in the operation’s security requirements.

Behavior Notes


Common Error Handling

All tools follow consistent error patterns:

Parameter Validation

Missing or invalid parameters return immediately with isError: true:

{
content: [{ type: "text", text: "Error message describing the issue" }],
isError: true
}

Operation Format

Operations must match serviceName/operationName:

Session Context

All tools require an active MCP session. Outside a valid session:

Session not found

Exceptions

Unexpected errors are caught and returned as:

{
content: [{ type: "text", text: error.message }],
isError: true
}

MCP Protocol Details

Protocol Version

2025-06-18

Tool Annotations

ToolreadOnlyHintdestructiveHintopenWorldHint
find_apitruetrue
learn_apitruetrue
call_apitruetrue

Message Format

JSON-RPC 2.0 over the configured transport (stdio, SSE, WebSocket).


Best Practices

Discovery First

Always use find_api before claiming an operation doesn’t exist:

1. find_api("create a payment intent")
2. learn_api("stripe/payment_intents.create", request: true)
3. call_api("stripe/payment_intents.create", arguments: {...})

Type Learning

Use learn_api before complex operations:

Authorization Handling

When call_api returns authorization_required:

  1. Extract the connect_url from the response
  2. Present it to the user as a clickable link
  3. After user authorizes, retry the operation

Error Recovery

Next Steps