Resources

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

bash
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-stream

If that works, the problem is your client. If it does not, it is the credential or the transport.


#401 mcp_unauthorized

CauseCheckFix
no Authorization headercurl -iadd it
the key lacks mcp:toolsGET /me → credential.scopemint 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 againstpoint BASE at the matching endpoint (https://ulexid.com/api/v1 or http://127.0.0.1:3001/api/v1)
the key expired or was revokedGET /tenants/current/api-keysmint a new one
you are using an OAuth token without the scopethe introspected scoperequest mcp:tools

The 401 carries a pointer to the OAuth 2.1 protected-resource metadata:

http
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"
bash
curl -sS "$BASE/.well-known/oauth-protected-resource" | jq

A 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

json
{
  "error": {
    "type": "not_found_error",
    "code": "mcp_tool_not_found",
    "message": "No tool named 'ulex_bootstrap_application'. Call ulex_list_tools.",
    "retryable": false
  }
}
json
{ "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 -32601ulex mcp_tool_not_found
tools/calll, tools/lists, tool/callulex_bootstrap_application does not exist
a transport or client bugthe argument name is wrong

#Tool errors are not protocol errors

This is the single most common client bug, and it is silent.

json
// Protocol failure. HTTP 200, no result, a JSON-RPC error object.
{ "jsonrpc": "2.0", "id": 7, "error": { "code": -32601, "message": "Method not found" } }
json
// 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 } }
ts
// 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 codeMeaning
-32700the body is not JSON
-32600wrong jsonrpc version, or a malformed frame
-32601the method does not exist
-32602the params do not match the schema
-32603our 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.

text
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

HeaderDirectionWhy it matters
Accept: application/json, text/event-streamrequestrequired on POST /mcp. Without it ulex returns 406
Content-Type: application/jsonrequestrequired
MCP-Protocol-Version: 2025-06-18requestecho the version you negotiated
Mcp-Session-Idresponse on initialize, request afterthe session handle. Carrying it is mandatory
DELETE /mcp with Mcp-Session-Idrequestterminates the session
bash
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"
SymptomCause
406 Not Acceptablemissing or wrong Accept
404 on the second callnot sending Mcp-Session-Id
404 after 24 hoursthe session expired. Re-initialize
202 where you expected a bodythat is a notification. Correct
a hanging requestyou are waiting for a body on a notification. There is none

#Parsing SSE

text
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.

ts
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.

json
{ "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 ofdo
ulex_create_user × 5005 × POST /scim/v2/Bulk with 100 operations
polling a deployment every 100 msevery 250 ms, or the deployment.succeeded webhook
polling sync statusevery 2 s, or the dsync.* webhook
ulex_simulate_login per assertionulex_mint_access_token
GET /audit-events in a loopone export with format=ndjson and a date window

#Common client misconfigurations

MisconfigurationSymptom
not sending Accept: application/json, text/event-stream406
parsing the whole body as JSONa JSON parse error on event: message
treating result.isError: true as successa tool failure silently becomes a no-op
passing environment to a tool400 unknown_parameter
putting an API key in a tool argumentit lands in the audit log, your transcript, and your vendor's logs
a JSON-RPC id reused across concurrent callsresponses get matched to the wrong request. Use unique ids
not handling 202 on a notificationa hang or a spurious error
stdio with the key on argvvisible in ps and /proc. Use ULEX_API_KEY in the environment
calling MCP over http://localhost in a client that blocks itthe 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 retryablean infinite loop on mfa_required or resource_exists

#stdio

bash
npx @ulexid/mcp-server
json
{
  "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

bash
# 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

  1. Run the 30-second check at the top.
  2. ulex_list_tools — if that works, your transport is fine and it is an argument name.
  3. The ulex error envelope has a docs_url. Open it; it is the specific page for that code.
  4. ulex_explain_error with the code.
  5. If it is a ulex defect, report it at security@ulexid.com with the request_id and the Mcp-Session-Id. See Responsible disclosure.

#Reference