fa-mcp-sdk 0.11.8 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,12 +22,17 @@ DEBUG=config-info
|
|
|
22
22
|
# AP-UPDATER - consul/access-points-updater
|
|
23
23
|
# fa-consul:reg | fa-consul:* - consul/cyclic-register
|
|
24
24
|
# fa-consul:curl - consul/prepare-consul-api
|
|
25
|
-
# token:auth
|
|
26
|
-
# mcp:tool
|
|
27
|
-
# mcp:resource
|
|
28
|
-
# mcp:notification
|
|
29
|
-
# mcp:prompt
|
|
30
|
-
# mcp:*
|
|
25
|
+
# token:auth - authentication: which auth method matched, token parsing/validation outcome
|
|
26
|
+
# mcp:tool - tools/call: tool name + arguments in, response (text or JSON) out
|
|
27
|
+
# mcp:resource - resources/list and resources/read: URI in, body out
|
|
28
|
+
# mcp:notification - all incoming notifications/* (method + params)
|
|
29
|
+
# mcp:prompt - prompts/list and prompts/get: name/args in, messages out
|
|
30
|
+
# mcp:* - all four MCP channels above at once
|
|
31
|
+
# mcp-handshake - HTTP transport: per-request dump (method, id, session routing, protocol, auth, IP)
|
|
32
|
+
# mcp-rpc - HTTP transport: one-line summary of every successful JSON-RPC response
|
|
33
|
+
#
|
|
34
|
+
#(session-lifecycle events, the -32600 "no valid session" rejection and JSON-RPC errors log always)
|
|
35
|
+
#
|
|
31
36
|
# ========================================================================
|
|
32
37
|
# AGENT TESTER - Built-in AI agent for testing MCP tools
|
|
33
38
|
# ========================================================================
|
|
@@ -18,7 +18,7 @@ npm install fa-mcp-sdk
|
|
|
18
18
|
| [03-configuration](03-configuration.md) | `appConfig`, YAML config, access points, cache, **`mcp.limits` (payload/result/timeout)**, **`mcp.pagination`**, **`mcp.resources` (MAY)**, **`mcp.rateLimit.scope` + `maxConcurrentPerSubject` (§14)**, **`webServer.trustProxy`**, **`webServer.tokenCheck.allowQueryToken` (§7.1)**, **/health & /ready**, **CORS hardening**, **MCP error codes** (`-32002…-32005`) | Server configuration, external services, transport-level hardening |
|
|
19
19
|
| [04-authentication](04-authentication.md) | JWT (**4 modes: legacyAesCtr / embedded / localKey / remoteJwks**), Basic auth, server tokens, **OAuth discovery + `/oauth/token` + JWKS**, **`requiredScopes` enforcement (§7.5)**, **`WWW-Authenticate` realm + invalid_token (§7.4)**, **HTTP 403 `forbidden` flag**, `createAuthMW()`, Token Generator, CLI Token Generator (mode-aware), JWT Generation API | Authentication setup |
|
|
20
20
|
| [05-ad-authorization](05-ad-authorization.md) | AD group authorization at HTTP/tool levels | AD group restrictions |
|
|
21
|
-
| [06-utilities](06-utilities.md) | `ServerError`, `normalizeHeaders`, logging, MCP debug switches (`DEBUG=mcp:*`), JSON-lines sink (`mcp.debug.logFile` → `emitTrace`), built-in debug tools (`mcp.debug.builtinTools`), Consul, graceful shutdown | Error handling, utilities, request tracing, post-mortem analysis |
|
|
21
|
+
| [06-utilities](06-utilities.md) | `ServerError`, `normalizeHeaders`, logging, MCP debug switches (`DEBUG=mcp:*`), **HTTP connection & RPC tracing (`DEBUG=mcp-handshake` / `mcp-rpc`, always-on session-lifecycle + `-32600` + error logging)**, JSON-lines sink (`mcp.debug.logFile` → `emitTrace`), built-in debug tools (`mcp.debug.builtinTools`), Consul, graceful shutdown | Error handling, utilities, request tracing, post-mortem analysis |
|
|
22
22
|
| [07-testing-and-operations](07-testing-and-operations.md) | Test clients (STDIO, HTTP, SSE, Streamable HTTP); universal `debug-tool` fixture covering every `CallToolResult` shape | Testing, deployment, exercising client code against image/audio/resource/error/delay variants |
|
|
23
23
|
| [08-agent-tester-and-headless-api](08-agent-tester-and-headless-api.md) | Agent Tester, Headless API, structured logging, automated testing, UI `data-testid` reference. **MCP Apps mode**: capability negotiation, `appCalls[]` / `app_calls[]`, widget iframe bridge, App Inspector tab | Agent-driven tool development, CLI automation, UI E2E tests, MCP Apps host for development |
|
|
24
24
|
| [09-database](09-database.md) | PostgreSQL sugar layer (`queryMAIN`, `execMAIN`, `getInsertSqlMAIN`, `getMergeSqlMAIN`, `mergeByBatch`), `pgvector`, secondary DBs | Database access, upserts, batching |
|
|
@@ -336,6 +336,48 @@ echo "DEBUG=mcp:tool,mcp:resource" >> .env
|
|
|
336
336
|
> `stdout` via `console.log`, so enabling `DEBUG=mcp:*` in STDIO mode **will corrupt the framing**
|
|
337
337
|
> the client sees. Use these switches with HTTP/SSE transport, or redirect stdout.
|
|
338
338
|
|
|
339
|
+
## HTTP Connection & RPC Tracing (`DEBUG=mcp-handshake`, `DEBUG=mcp-rpc`)
|
|
340
|
+
|
|
341
|
+
Separate from the `mcp:*` channel switches above, the **Streamable HTTP transport** carries its own
|
|
342
|
+
connection- and response-level tracing in `web/server-http.ts`. These switches use hyphenated names
|
|
343
|
+
(`mcp-handshake`, `mcp-rpc`) and are read straight from the comma-split `DEBUG` env var — they do
|
|
344
|
+
**not** go through the `af-tools-ts` `Debug()` machinery, so they are not covered by `mcp:*` or `*`.
|
|
345
|
+
List them explicitly, e.g. `DEBUG=mcp-handshake,mcp-rpc`. They exist to answer the two questions the
|
|
346
|
+
`mcp:*` taps cannot: *why did the client get a session/protocol error?* and *what did the server
|
|
347
|
+
actually send back?*
|
|
348
|
+
|
|
349
|
+
| Env value | What it logs |
|
|
350
|
+
|-----------------------|---------------------------------------------------------------------------------------|
|
|
351
|
+
| *(always on)* | Session created / closed / transport-closed (with active-session count); the `-32600` "no valid session" rejection with the reason. |
|
|
352
|
+
| `DEBUG=mcp-handshake` | Per-request dump for every `/mcp` call: JSON-RPC method + id, short session id, routing hit/miss, protocol version, `Accept` / `Content-Type`, whether an auth header is present, and client IP. |
|
|
353
|
+
| `DEBUG=mcp-rpc` | One-line summary of every **successful** JSON-RPC response (status, ids, `result=ok` / notifications). |
|
|
354
|
+
|
|
355
|
+
Two things always log regardless of the switches, because they are otherwise silent failure modes:
|
|
356
|
+
|
|
357
|
+
- **The `-32600` rejection.** When a request reaches `/mcp` without a valid session and is not an
|
|
358
|
+
`initialize`, the server now logs *why* — the client must send `initialize` first or echo a valid
|
|
359
|
+
`mcp-session-id` header — and notes when the supplied session id is unknown or expired (with the
|
|
360
|
+
count of known sessions). This is the trace to look for when the client reports `-32600` but the
|
|
361
|
+
server log was previously empty.
|
|
362
|
+
- **Every JSON-RPC error response.** A response tee on `POST /mcp` and the `GET`/`DELETE` session
|
|
363
|
+
routes captures the outgoing body, parses it (auto-detecting a plain `application/json` answer vs.
|
|
364
|
+
the `data:` frames of an SSE stream), and logs each error's HTTP status, request id, `code`,
|
|
365
|
+
`message`, and truncated `data`, together with the originating request summary. The capture is
|
|
366
|
+
capped at 256 KB per response so a long SSE stream cannot exhaust memory (`[capture truncated]`
|
|
367
|
+
marks a hit), and the trace is wrapped so it can never break the real response.
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
# Why is the client getting "no valid session" / -32600? (handshake dump on every request)
|
|
371
|
+
DEBUG=mcp-handshake yarn start
|
|
372
|
+
|
|
373
|
+
# Also summarise successful responses (otherwise only errors are logged)
|
|
374
|
+
DEBUG=mcp-handshake,mcp-rpc yarn start
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
> These switches are HTTP-transport only — STDIO never opens sessions, so they have no effect there.
|
|
378
|
+
> They are safe to leave off in production; the always-on session-lifecycle and error lines are the
|
|
379
|
+
> ones worth keeping in normal operation.
|
|
380
|
+
|
|
339
381
|
### Extending with Custom Debug Categories
|
|
340
382
|
|
|
341
383
|
Add your own switches with the same `Debug()` helper from `af-tools-ts`:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fa-mcp-sdk",
|
|
3
3
|
"productName": "FA MCP SDK",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.10",
|
|
5
5
|
"description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/core/index.js",
|