Error Reference

Common errors returned by TengineAI's MCP endpoint and management API, with causes and fixes.


MCP / Tool Execution Errors

These errors occur when the model attempts to connect or execute a tool.

HTTP StatusErrorCauseFix
401 UnauthorizedInvalid or inactive API keyThe authorization_token in mcp_servers is wrong, revoked, or from a different projectVerify TENGINEAI_API_KEY matches the key in your project's Integrations tab
401 UnauthorizedInvalid member assertionmember_assertion JWT failed signature verification or has expiredEnsure exp ≤ 60s TTL, kid matches a registered assertion key, aud is tengine:project:<project_id>
401 UnauthorizedMember JWT has expiredThe tng_mst_... session token is past its 15-minute TTLMint a new session token — see the caching pattern
403 ForbiddenTool not enabled for this projectThe model tried to call a tool that isn't enabledConfirm is_enabled = true for the tool
403 Forbiddenmember_external_id mode disabled in productionUsing member_external_id field instead of member_assertionUse member_assertion (customer-signed JWT) in production
403 ForbiddenMember context requiredTool has require_member: true but was called with a plain API keyUse a member session token (tng_mst_...)
500 Internal Server ErrorTool execution failedTengineAI encountered an error calling your API endpointCheck your server logs; verify your endpoint is reachable and returning valid responses
502 Bad GatewayUpstream tool call failedYour API returned a non-2xx responseCheck your server logs; verify the endpoint path, method, and response format

Session Token Endpoint Errors

Errors from POST /api/v1/mcp/session-token:

HTTP StatusDetailCauseFix
400 Bad RequestProvide member_assertion or member_external_idRequest body is empty or missing both fieldsInclude member_assertion in the request body
400 Bad RequestCould not resolve member_external_idsub claim in the assertion is missing or not a stringEnsure sub is a non-empty string
400 Bad RequestAPI key missing project or integrationThe API key isn't associated with an integrationRe-check the key; create it from an Integration, not from project settings
401 UnauthorizedInvalid or inactive API keyThe API key in the Authorization header is wrongCheck TENGINEAI_API_KEY
401 UnauthorizedInvalid member assertion: MISSING_KIDJWT header is missing kidAdd headers={"kid": "your-key-id"} when encoding the assertion
401 UnauthorizedInvalid member assertion: KEY_NOT_FOUNDNo active assertion key matches the kidRegister the public key first, or check the key is still active
401 UnauthorizedInvalid member assertion: AUD_MISMATCHaud doesn't match tengine:project:<project_id>Verify TENGINEAI_PROJECT_ID and construct aud as tengine:project:{project_id}
401 UnauthorizedInvalid member assertion: EXPIREDAssertion JWT is past its expMint a fresh assertion — keep TTL at 60s
401 UnauthorizedInvalid member assertion: INVALID_SIGNATUREJWT was not signed with the registered private keyVerify the private key matches the public key registered for that kid

Custom Tool Errors

HTTP StatusDetailCauseFix
400 Bad RequestReserved variable cannot be provided as user inputModel passed member_id, project_id, or integration_id as a tool argumentRemove those from input_schema — they are auto-injected
400 Bad Requestbase_url must use HTTPSbase_url uses http://HTTPS is always required; use a tunnel (ngrok) to expose a local server
400 Bad Requestendpoint_path must start with /Path template missing leading slashPrepend / to the path
403 ForbiddenMember context required for this toolTool has require_member: true but the request used a plain API keyAuthenticate with a member session token (tng_mst_...)
500 Internal Server ErrorFailed to decrypt auth secretencrypted_auth_secret is corruptedRe-register the tool with a fresh secret value
500 Internal Server ErrorTool execution timed outYour API endpoint did not respond within the timeout windowCheck your server for slow queries or cold start latency; optimize the endpoint
502 Bad GatewayUpstream tool call failed — non-2xx responseYour API returned an error statusCheck your server logs; confirm the endpoint path, method, and auth are correct
502 Bad GatewayUpstream tool call failed — connection errorYour API is unreachableConfirm base_url is publicly accessible; check firewall/VPC rules

Tool Registration Errors

Errors from POST /api/v1/custom-tools:

HTTP StatusDetailCauseFix
400 Bad Requestbase_url must be origin-only (no paths)base_url includes a path like /v1Use origin only: https://api.example.com
400 Bad Requestencrypted_auth_secret is required when auth_strategy is 'hmac_signature'Missing secret for a signed toolAdd encrypted_auth_secret to the tool config
400 Bad Requestendpoint_path uses {{member_id}} but require_member=FalseTemplate references member ID without requiring a sessionSet require_member: true
422 Unprocessable EntityValidation errorMalformed JSON schema or invalid field valueCheck the error detail for the specific field

Assertion Key Registration Errors

Errors from POST /api/v1/assertion-keys:

HTTP StatusDetailCauseFix
400 Bad RequestInvalid public key formatPEM is malformed or wrong key typeRe-export: openssl ec -in private_key.pem -pubout -out public_key.pem
400 Bad RequestUnsupported algorithmAlgorithm not in ES256, ES384, Ed25519, RS256Use a supported algorithm
409 Conflictkid already exists for this projectA key with that kid is already registeredUse a different kid, or deactivate the existing key first

Debugging Tips

401 on a tool that was working — Your session token may have expired. Member session tokens have a 15-minute TTL. Implement the caching pattern in User-Scoped Quick Start to handle refresh transparently.

502 from a custom tool — Your API returned a non-2xx response. Add logging middleware to print all incoming requests and confirm your endpoint is receiving and handling the request correctly.

Signature verification failures — Print the canonical string your server constructs and compare it character-by-character with what TengineAI builds. Use the curl simulation in Build Your First Tool to test independently.

Model says it has no tools — The model can only see tools enabled for the project your token belongs to. Check is_enabled for each tool and confirm you're using the right API key for the right project.