File contents API: Quick Usage & Testing Guide
Purpose: Help LLMs and scripts call ContextForge API reliably with correct auth, payloads, and common flows.
Base URL: http://localhost:4444 (production via make serve), or http://127.0.0.1:8000 (dev via make dev).
OpenAPI spec: Available at /openapi.json when server is running
Swagger UI: Available at /docs when server is running (requires auth)
Authentication
Token Scoping (affects what resources you can see)
The teams claim in your JWT determines resource visibility:
No teams key → PUBLIC-ONLY (secure default, can only see visibility=public resources)
teams: null + is_admin: true → ADMIN BYPASS (see all resources)
teams: [] → PUBLIC-ONLY (even for admins)
teams: ["team-uuid"] → Team + Public resources
Generate team-scoped token:export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token \
--username user@example.com --exp 60 --secret KEY --teams '["team-uuid"]' | tr -d '\n')
Generate public-only token (for automation):export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token \
--username ci@example.com --exp 60 --secret KEY --teams '[]' | tr -d '\n')
Full documentation: docs/docs/manage/rbac.md
Health & Metadata
Health: GET /health (no auth) — returns basic health status.curl -s http://localhost:4444/health | jq
Readiness: GET /ready (no auth)curl -s http://localhost:4444/ready | jq
Version/diagnostics (auth): GET /versioncurl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/version | jq
Servers
List servers:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/servers?include_inactive=false" | jq
Create server:curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"server": {
"name": "fast-time",
"description": "Demo server",
"tags": ["demo"]
},
"visibility": "private"
}' \
http://localhost:4444/servers | jq
Get server details:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/servers/<server_id> | jq
Server tools list:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/servers/<server_id>/tools | jq
JSON‑RPC Tool Calls
Endpoint: POST /rpc (auth). Body is JSON‑RPC 2.0.
Example calling a tool named fast-time-git-status:curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "fast-time-git-status",
"params": {"repo_path": "/path/to/repo"}
}' \
http://localhost:4444/rpc | jq
Prompts
List prompts:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/prompts?include_inactive=false" | jq
Get a prompt by name (no args):curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/prompts/<prompt_name> | jq
Render a prompt with args (POST body is a dict of key→string):curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"user_input": "hello"}' \
http://localhost:4444/prompts/<prompt_name> | jq
Resources
List resources:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/resources?include_inactive=false" | jq
Read a resource (URI path parameter must be URL‑encoded):URI=$(python3 - <<'PY'
import urllib.parse
print(urllib.parse.quote('http://example.com/file.txt', safe=''))
PY
)
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/resources/${URI}" | jq
Subscribe to a resource (server‑sent updates):curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/resources/subscribe/${URI}
SSE Streams
Common Query Parameters
include_inactive (bool): include disabled entities.
tags (comma‑separated or repeated): filter by tag.
team_id (str): team scoping.
visibility (str): private|team|public.
Auth & Errors
401 Unauthorized when the bearer token is missing/invalid.
422 Validation Error for malformed payloads or params.
Plugins may block requests in enforce mode; look for a structured violation in the response.
Gateways (MCP Server Registry)
List gateways:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/gateways?include_inactive=false" | jq
Create gateway (register an external MCP server):curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "http://localhost:9000",
"name": "my-mcp-server",
"description": "Example MCP server"
}' \
http://localhost:4444/gateways | jq
Refresh gateway (re-discover tools/resources):curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/gateways/<gateway_id>/refresh | jq
Tools
List tools:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/tools?include_inactive=false" | jq
Get tool details:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/tools/<tool_name> | jq
A2A Agents (Agent-to-Agent)
List A2A agents:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
"http://localhost:4444/a2a?include_inactive=false" | jq
Create A2A agent:curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-agent",
"description": "Agent description",
"url": "http://localhost:9001"
}' \
http://localhost:4444/a2a | jq
WebSocket Transport
Admin API
Get system stats (requires admin API enabled):curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/admin/api/stats | jq
Export configuration:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/admin/export | jq
Import/Export
Export all configuration:curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
http://localhost:4444/export > backup.json
Import configuration:curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d @backup.json \
"http://localhost:4444/import?conflict_strategy=skip" | jq
Well-Known Endpoints
Tips
Prefer Authorization header (bearer token) over jwt_token cookie.
For dev: make dev runs the app on :8000 with hot reload; production make serve runs Gunicorn on :4444.
If resources or prompts contain reserved characters, URL‑encode path params.
Pagination: Most list endpoints support cursor and limit params for cursor-based pagination.
Tags filtering: Use tags=tag1,tag2 query parameter to filter by tags.
Team scoping: Use team_id query parameter to filter by team.
1 --- 2 name: 076-api-08409a71 3 description: API: Quick Usage & Testing Guide 4 --- 5 API: Quick Usage & Testing Guide 6 7 - Purpose: Help LLMs and scripts call ContextForge API reliably with correct auth, payloads, and common flows. 8 - Base URL: `http://localhost:4444` (production via `make serve`), or `http://127.0.0.1:8000` (dev via `make dev`). 9 - OpenAPI spec: Available at `/openapi.json` when server is running 10 - Swagger UI: Available at `/docs` when server is running (requires auth) 11 12 **Authentication** 13 - Scheme: HTTP Bearer (JWT). Prefer the `Authorization` header over cookies. 14 - Generate a short‑lived token and export it: 15 ```bash 16 export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token \ 17 --username admin@example.com --exp 60 --secret KEY | tr -d '\n') 18 ``` 19 - Use in requests: 20 - Header: `Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN` 21 - Many endpoints also accept an optional `jwt_token` cookie parameter, but the header is preferred. 22 23 **Token Scoping (affects what resources you can see)** 24 25 - The `teams` claim in your JWT determines resource visibility: 26 - No `teams` key → PUBLIC-ONLY (secure default, can only see `visibility=public` resources) 27 - `teams: null` + `is_admin: true` → ADMIN BYPASS (see all resources) 28 - `teams: []` → PUBLIC-ONLY (even for admins) 29 - `teams: ["team-uuid"]` → Team + Public resources 30 - Generate team-scoped token: 31 ```bash 32 export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token \ 33 --username user@example.com --exp 60 --secret KEY --teams '["team-uuid"]' | tr -d '\n') 34 ``` 35 - Generate public-only token (for automation): 36 ```bash 37 export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token \ 38 --username ci@example.com --exp 60 --secret KEY --teams '[]' | tr -d '\n') 39 ``` 40 - Full documentation: `docs/docs/manage/rbac.md` 41 42 **Health & Metadata** 43 - Health: `GET /health` (no auth) — returns basic health status. 44 ```bash 45 curl -s http://localhost:4444/health | jq 46 ``` 47 - Readiness: `GET /ready` (no auth) 48 ```bash 49 curl -s http://localhost:4444/ready | jq 50 ``` 51 - Version/diagnostics (auth): `GET /version` 52 ```bash 53 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 54 http://localhost:4444/version | jq 55 ``` 56 57 **Servers** 58 - List servers: 59 ```bash 60 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 61 "http://localhost:4444/servers?include_inactive=false" | jq 62 ``` 63 - Create server: 64 ```bash 65 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 66 -H "Content-Type: application/json" \ 67 -d '{ 68 "server": { 69 "name": "fast-time", 70 "description": "Demo server", 71 "tags": ["demo"] 72 }, 73 "visibility": "private" 74 }' \ 75 http://localhost:4444/servers | jq 76 ``` 77 - Get server details: 78 ```bash 79 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 80 http://localhost:4444/servers/<server_id> | jq 81 ``` 82 - Server tools list: 83 ```bash 84 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 85 http://localhost:4444/servers/<server_id>/tools | jq 86 ``` 87 88 **JSON‑RPC Tool Calls** 89 - Endpoint: `POST /rpc` (auth). Body is JSON‑RPC 2.0. 90 - Example calling a tool named `fast-time-git-status`: 91 ```bash 92 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 93 -H "Content-Type: application/json" \ 94 -d '{ 95 "jsonrpc": "2.0", 96 "id": 1, 97 "method": "fast-time-git-status", 98 "params": {"repo_path": "/path/to/repo"} 99 }' \ 100 http://localhost:4444/rpc | jq 101 ``` 102 103 **Prompts** 104 - List prompts: 105 ```bash 106 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 107 "http://localhost:4444/prompts?include_inactive=false" | jq 108 ``` 109 - Get a prompt by name (no args): 110 ```bash 111 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 112 http://localhost:4444/prompts/<prompt_name> | jq 113 ``` 114 - Render a prompt with args (POST body is a dict of key→string): 115 ```bash 116 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 117 -H "Content-Type: application/json" \ 118 -d '{"user_input": "hello"}' \ 119 http://localhost:4444/prompts/<prompt_name> | jq 120 ``` 121 122 **Resources** 123 - List resources: 124 ```bash 125 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 126 "http://localhost:4444/resources?include_inactive=false" | jq 127 ``` 128 - Read a resource (URI path parameter must be URL‑encoded): 129 ```bash 130 URI=$(python3 - <<'PY' 131 import urllib.parse 132 print(urllib.parse.quote('http://example.com/file.txt', safe='')) 133 PY 134 ) 135 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 136 "http://localhost:4444/resources/${URI}" | jq 137 ``` 138 - Subscribe to a resource (server‑sent updates): 139 ```bash 140 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 141 http://localhost:4444/resources/subscribe/${URI} 142 ``` 143 144 **SSE Streams** 145 - Global SSE endpoint (auth): 146 ```bash 147 curl -N -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 148 http://localhost:4444/sse 149 ``` 150 - Per‑server SSE endpoint: 151 ```bash 152 curl -N -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 153 http://localhost:4444/servers/<server_id>/sse 154 ``` 155 156 **Common Query Parameters** 157 - `include_inactive` (bool): include disabled entities. 158 - `tags` (comma‑separated or repeated): filter by tag. 159 - `team_id` (str): team scoping. 160 - `visibility` (str): `private|team|public`. 161 162 **Auth & Errors** 163 - 401 Unauthorized when the bearer token is missing/invalid. 164 - 422 Validation Error for malformed payloads or params. 165 - Plugins may block requests in `enforce` mode; look for a structured violation in the response. 166 167 **Gateways (MCP Server Registry)** 168 - List gateways: 169 ```bash 170 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 171 "http://localhost:4444/gateways?include_inactive=false" | jq 172 ``` 173 - Create gateway (register an external MCP server): 174 ```bash 175 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 176 -H "Content-Type: application/json" \ 177 -d '{ 178 "url": "http://localhost:9000", 179 "name": "my-mcp-server", 180 "description": "Example MCP server" 181 }' \ 182 http://localhost:4444/gateways | jq 183 ``` 184 - Refresh gateway (re-discover tools/resources): 185 ```bash 186 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 187 http://localhost:4444/gateways/<gateway_id>/refresh | jq 188 ``` 189 190 **Tools** 191 - List tools: 192 ```bash 193 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 194 "http://localhost:4444/tools?include_inactive=false" | jq 195 ``` 196 - Get tool details: 197 ```bash 198 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 199 http://localhost:4444/tools/<tool_name> | jq 200 ``` 201 202 **A2A Agents (Agent-to-Agent)** 203 - List A2A agents: 204 ```bash 205 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 206 "http://localhost:4444/a2a?include_inactive=false" | jq 207 ``` 208 - Create A2A agent: 209 ```bash 210 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 211 -H "Content-Type: application/json" \ 212 -d '{ 213 "name": "my-agent", 214 "description": "Agent description", 215 "url": "http://localhost:9001" 216 }' \ 217 http://localhost:4444/a2a | jq 218 ``` 219 220 **WebSocket Transport** 221 - Connect to WebSocket for bidirectional MCP communication: 222 ```bash 223 websocat "ws://localhost:4444/ws" -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" 224 ``` 225 - Per-server WebSocket: 226 ```bash 227 websocat "ws://localhost:4444/servers/<server_id>/ws" -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" 228 ``` 229 230 **Admin API** 231 - Get system stats (requires admin API enabled): 232 ```bash 233 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 234 http://localhost:4444/admin/api/stats | jq 235 ``` 236 - Export configuration: 237 ```bash 238 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 239 http://localhost:4444/admin/export | jq 240 ``` 241 242 **Import/Export** 243 - Export all configuration: 244 ```bash 245 curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 246 http://localhost:4444/export > backup.json 247 ``` 248 - Import configuration: 249 ```bash 250 curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \ 251 -H "Content-Type: application/json" \ 252 -d @backup.json \ 253 "http://localhost:4444/import?conflict_strategy=skip" | jq 254 ``` 255 256 **Well-Known Endpoints** 257 - MCP discovery (/.well-known/mcp.json): 258 ```bash 259 curl -s http://localhost:4444/.well-known/mcp.json | jq 260 ``` 261 262 **Tips** 263 - Prefer Authorization header (bearer token) over `jwt_token` cookie. 264 - For dev: `make dev` runs the app on `:8000` with hot reload; production `make serve` runs Gunicorn on `:4444`. 265 - If resources or prompts contain reserved characters, URL‑encode path params. 266 - Pagination: Most list endpoints support `cursor` and `limit` params for cursor-based pagination. 267 - Tags filtering: Use `tags=tag1,tag2` query parameter to filter by tags. 268 - Team scoping: Use `team_id` query parameter to filter by team.
tools-only/X-Skills/tree/main/development/076-api_08409a71 commit 66b95cec27
Frequently asked questions How do I install the 076 API 08409a71 skill? Run npx skillmds@latest add tools-only/076-api-08409a71 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the 076 API 08409a71 skill do? API: Quick Usage & Testing Guide It is listed under Integrations & APIs on SkillMD.
Is 076 API 08409a71 safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with 076 API 08409a71? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is 076 API 08409a71 free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published 076 API 08409a71? tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.