MCP issues
Troubleshooting the ulex MCP endpoint: transport and session headers, JSON-RPC versus tool errors, authentication and RFC 9728, SSE parsing, common client misconfigurations, rate limits, and how to inspect a session by hand.
#The 30-second check
BASE="https://ulexid.com/api/v1"
# 1. Is the endpoint alive?
curl -sS "$BASE/health" | jq -r .healthy
# 2. Does a raw initialize work?
curl -sS -D/tmp/h -X POST "$BASE/mcp" \
-H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}'
grep -i 'mcp-session-id' /tmp/h # → mcp-session-id: 4f7a1c9e-…
grep -i 'content-type' /tmp/h # → content-type: text/event-streamIf that works, the problem is your client. If it does not, it is the credential or the transport.
#401 mcp_unauthorized
| Cause | Check | Fix |
|---|---|---|
no Authorization header | curl -i | add it |
the key lacks mcp:tools | GET /me → credential.scope | mint a new key with mcp:tools |
the key was issued for another endpoint (for example, local 127.0.0.1 vs hosted ulexid.com) | GET /me or the host you bootstrapped against | point BASE at the matching endpoint (https://ulexid.com/api/v1 or http://127.0.0.1:3001/api/v1) |
| the key expired or was revoked | GET /tenants/current/api-keys | mint a new one |
| you are using an OAuth token without the scope | the introspected scope | request mcp:tools |
The 401 carries a pointer to the OAuth 2.1 protected-resource metadata:
HTTP/2 401 Unauthorized
www-authenticate: Bearer realm="ulex", error="invalid_token",
error_description="An access token is required to call ulex MCP tools.",
resource_metadata="https://ulexid.com/api/v1/.well-known/oauth-protected-resource"curl -sS "$BASE/.well-known/oauth-protected-resource" | jqA conformant client follows resource_metadata, discovers the authorization server, and runs authorization-code-with-PKCE with resource=https://ulexid.com/api/v1 (RFC 8707). The resulting token is a normal ulex access token and works on REST too.
A client that does not follow resource_metadata will loop on 401 forever. That is a client bug; the metadata is the fix, and it is documented.
#404 mcp_tool_not_found
{
"error": {
"type": "not_found_error",
"code": "mcp_tool_not_found",
"message": "No tool named 'ulex_bootstrap_application'. Call ulex_list_tools.",
"retryable": false
}
}{ "name": "ulex_list_tools", "arguments": { "include_schemas": true, "filter": "bootstrap" } }Tool names are exact and all start with ulex_. A JSON-RPC -32601 instead of a ulex error means the method name is wrong, not the tool name:
JSON-RPC -32601 | ulex mcp_tool_not_found |
|---|---|
tools/calll, tools/lists, tool/call | ulex_bootstrap_application does not exist |
| a transport or client bug | the argument name is wrong |
#Tool errors are not protocol errors
This is the single most common client bug, and it is silent.
// Protocol failure. HTTP 200, no result, a JSON-RPC error object.
{ "jsonrpc": "2.0", "id": 7, "error": { "code": -32601, "message": "Method not found" } }// Tool failure. HTTP 200, a result, isError: true, the ulex envelope inside.
{ "jsonrpc": "2.0", "id": 7, "result": { "content": [{ "type": "text", "text": "{\"error\":{\"type\":\"permission_error\",\"code\":\"insufficient_scope\",…}}" }], "isError": true } }// Wrong: reads the HTTP status and calls it a success.
if (res.ok) return JSON.parse(res.body);
// Right
const body = await res.json() as McpResponse;
if (body.error) throw new JsonRpcError(body.error.code, body.error.message);
if (body.result.isError) throw new UlexError(JSON.parse(body.result.content[0].text));
return body.result.structuredContent;| JSON-RPC code | Meaning |
|---|---|
-32700 | the body is not JSON |
-32600 | wrong jsonrpc version, or a malformed frame |
-32601 | the method does not exist |
-32602 | the params do not match the schema |
-32603 | our fault |
A tool failure is not -32603. If you map isError: true to -32603, you lose retryable and every 429 becomes an unretryable protocol error.
#Read structuredContent
Every ulex tool returns the resource twice: as a JSON string in content[0].text, and as a typed object in structuredContent.
event: message
data: {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"{\"application\":{\"id\":\"app_01M3PSV7J8TBSPHG95CYSEX32B\"},…}"}],"structuredContent":{"application":{"id":"app_01M3PSV7J8TBSPHG95CYSEX32B"},"organization":{"id":"org_01M3PSV8HGTKQFCAYF9GDWGN3C"}},"isError":false}}Prefer structuredContent. Fall back to JSON.parse(content[0].text) only if your client drops unknown fields, which is a client limitation rather than something to work around.
#Headers
| Header | Direction | Why it matters |
|---|---|---|
Accept: application/json, text/event-stream | request | required on POST /mcp. Without it ulex returns 406 |
Content-Type: application/json | request | required |
MCP-Protocol-Version: 2025-06-18 | request | echo the version you negotiated |
Mcp-Session-Id | response on initialize, request after | the session handle. Carrying it is mandatory |
DELETE /mcp with Mcp-Session-Id | request | terminates the session |
SESSION=$(curl -sS -D- -o /dev/null -X POST "$BASE/mcp" \
-H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}' \
| grep -i '^mcp-session-id' | tr -d '\r' | cut -d' ' -f2)
curl -sS -X POST "$BASE/mcp" \
-H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-H "Mcp-Session-Id: $SESSION" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' # → 202 Accepted, empty body
curl -sS -X POST "$BASE/mcp" \
-H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-H "Mcp-Session-Id: $SESSION" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"ulex_list_tools","arguments":{"include_schemas":false}}}'
curl -sS -X DELETE "$BASE/mcp" -H "Authorization: Bearer $ULEX_API_KEY" -H "Mcp-Session-Id: $SESSION"| Symptom | Cause |
|---|---|
406 Not Acceptable | missing or wrong Accept |
404 on the second call | not sending Mcp-Session-Id |
404 after 24 hours | the session expired. Re-initialize |
202 where you expected a body | that is a notification. Correct |
| a hanging request | you are waiting for a body on a notification. There is none |
#Parsing SSE
event: message
data: {"jsonrpc":"2.0","id":2,"result":{…}}The frame ends with a blank line. A naive line reader that splits on \n and tries to parse every line will fail on event: message and on the blank line.
export function* parseSse(raw: string): Generator<unknown> {
for (const frame of raw.split("\n\n")) {
const data = frame
.split("\n")
.filter((l) => l.startsWith("data:"))
.map((l) => l.slice(5).trim())
.join("");
if (data) yield JSON.parse(data);
}
}Or use fetch with a ReadableStream reader, which is what a real client does. The split-on-blank-line version is for debugging.
#429 too_many_requests
MCP calls use the general per-IP bucket: 600 sustained requests/minute and 1,200 burst per Lambda container. Pricing is usage-based; resource counts are informational and no plan quotas apply.
{ "error": { "type": "rate_limited", "code": "too_many_requests", "message": "Rate limit exceeded. Back off and retry." } }Honor Retry-After; batch bulk work to reduce requests and usage.
| Instead of | do |
|---|---|
ulex_create_user × 500 | 5 × POST /scim/v2/Bulk with 100 operations |
| polling a deployment every 100 ms | every 250 ms, or the deployment.succeeded webhook |
| polling sync status | every 2 s, or the dsync.* webhook |
ulex_simulate_login per assertion | ulex_mint_access_token |
GET /audit-events in a loop | one export with format=ndjson and a date window |
#Common client misconfigurations
| Misconfiguration | Symptom |
|---|---|
not sending Accept: application/json, text/event-stream | 406 |
| parsing the whole body as JSON | a JSON parse error on event: message |
treating result.isError: true as success | a tool failure silently becomes a no-op |
passing environment to a tool | 400 unknown_parameter |
| putting an API key in a tool argument | it lands in the audit log, your transcript, and your vendor's logs |
a JSON-RPC id reused across concurrent calls | responses get matched to the wrong request. Use unique ids |
not handling 202 on a notification | a hang or a spurious error |
stdio with the key on argv | visible in ps and /proc. Use ULEX_API_KEY in the environment |
calling MCP over http://localhost in a client that blocks it | the client refuses before ulex sees it. Use the client's local-origin flag, or a local TLS terminator |
retrying a tool call after isError: true without reading retryable | an infinite loop on mfa_required or resource_exists |
#stdio
npx @ulexid/mcp-server{
"mcpServers": {
"ulex": { "command": "npx", "args": ["@ulexid/mcp-server"], "env": { "ULEX_API_KEY": "…" } }
}
}The key comes from the environment, never from argv — argv is world-readable in /proc and appears in ps output for every process on the machine.
stdio is out of scope for SOC 2: it runs on your machine, and its security is yours. The REST and Streamable HTTP surfaces are in scope. See the compliance matrix.
#Inspecting a session by hand
# What is the server version, and what does it think it supports?
curl -sS -X POST "$BASE/mcp" -H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}' \
| sed -n 's/^data: //p' | jq '.result.serverInfo, .result.instructions'
# Every tool, with its schema
curl -sS -X POST "$BASE/mcp" -H "Authorization: Bearer $ULEX_API_KEY" \
-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" -H "Mcp-Session-Id: $SESSION" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
| sed -n 's/^data: //p' | jq '.result.tools | length'The instructions field in the initialize response tells the agent that the tenant context is derived from the credential, to start with ulex_list_tools, and that ulex_bootstrap_app provisions in one call. A client that ignores it is working blind.
#Still stuck
- Run the 30-second check at the top.
ulex_list_tools— if that works, your transport is fine and it is an argument name.- The ulex error envelope has a
docs_url. Open it; it is the specific page for that code. ulex_explain_errorwith the code.- If it is a ulex defect, report it at
security@ulexid.comwith therequest_idand theMcp-Session-Id. See Responsible disclosure.