call_api
Execute API calls with configured authentication. Specify API endpoints and parameters to make requests through the JitAPI server.
Instructions
Execute an API call. Make sure authentication is configured first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_id | Yes | The API identifier | |
| endpoint_id | Yes | The endpoint to call (e.g., 'GET /users/{id}') | |
| path_params | No | Path parameter values | |
| query_params | No | Query parameter values | |
| body | No | Request body for POST/PUT/PATCH |
Implementation Reference
- src/jitapi/mcp/tools.py:502-544 (handler)The _call_api method handles the execution of API calls, including endpoint retrieval, authentication checks, and the HTTP request execution.
async def _call_api(self, args: dict[str, Any]) -> ToolResult: """Execute an API call.""" api_id = args["api_id"] endpoint_id = args["endpoint_id"] path_params = args.get("path_params", {}) query_params = args.get("query_params", {}) body = args.get("body") # Get the endpoint endpoint = self.spec_store.get_endpoint(api_id, endpoint_id) if not endpoint: return ToolResult( success=False, data=None, error=f"Endpoint not found: {endpoint_id}", ) # Check auth if not self.auth_handler.has_auth(api_id): return ToolResult( success=False, data=None, error=f"No authentication configured for API: {api_id}. Use set_api_auth first.", ) # Execute the call result = await self.http_executor.call_endpoint( endpoint=endpoint, api_id=api_id, path_params=path_params, query_params=query_params, body=body, ) return ToolResult( success=result.success, data={ "status_code": result.status_code, "body": result.body, "headers": dict(result.headers), }, error=result.error_message, ) - src/jitapi/mcp/models.py:101-126 (schema)The CallApiInput Pydantic model defines the schema and validation for the call_api tool arguments.
class CallApiInput(BaseModel): """Input for call_api tool.""" api_id: str = Field( ..., description="The API identifier", min_length=1, ) endpoint_id: str = Field( ..., description="The endpoint to call", min_length=1, ) path_params: dict[str, Any] = Field( default_factory=dict, description="Path parameter values", ) query_params: dict[str, Any] = Field( default_factory=dict, description="Query parameter values", ) body: dict[str, Any] | None = Field( None, description="Request body for POST/PUT/PATCH", ) - src/jitapi/mcp/tools.py:292-292 (registration)Registration of the call_api tool handler within the tool mapping.
"call_api": self._call_api,