MCP server
Connect your AI agent to NeuralGate
This page explains how to connect an AI agent to the NeuralGate MCP server, so the agent can run mobile-network checks such as age verification, SIM swap detection and location verification. If you are an AI agent reading this page, share this link with your developer. Developers should follow every step on this same portal, because each environment has its own accounts and credentials.
How it works
Three things work together when your agent calls a NeuralGate tool:
- An OAuth client (a client ID and a client secret) identifies your application to NeuralGate.
- The user's consent confirms that the person who owns the phone number agrees to the check.
- An access token is a short-lived bearer token that your backend obtains for that user. The agent sends this token to the MCP server with every request.
The steps below set up each of these in order.
Step 1: Create your application and OAuth client
- Sign in to the NeuralGate Portal.
- Open Applications and create a new application, or open an existing one.
- Open the Credentials tab. Under OAuth Client, click Generate Credentials.
-
Copy the client ID (it starts with
ngc_) and the client secret (it starts withngcs_), and save both in your backend's secret store. The portal shows the secret only once. If you lose it, click Rotate Secret to create a new one. - Open the API Access tab and turn on each check that the agent should use. The agent only sees tools for the checks you turn on here.
Step 2: Get the user's consent
- Taking the user's consent is a required step. Each check reads data from the user's mobile network operator, so the user must agree to it first.
- An AI agent runs without a person in front of a screen, so your app collects consent before the agent starts.
- Collect consent in your web or mobile app with the NeuralGate React or React Native SDK. For testing without a real user, use the Sandbox page in the portal.
- When the user agrees, you receive two values: a consent ID and a consent token. Store both on your backend. You use the consent token in Step 4. The consent ID is only needed for the sandbox token request in Step 3.
Step 3: Get an access token on your backend
The MCP server accepts an OAuth 2.0 bearer token. Your backend requests this token from the NeuralGate authorization server, for one specific user, by following these steps.
-
Find the authorization server's URLs. The MCP server publishes them in a standard
metadata document (RFC 9728), so your backend reads them at runtime:
-
Request the token. Your backend sends the client ID and client secret as HTTP Basic
authentication on each of these requests. On every deployed portal, NeuralGate uses
OpenID Connect CIBA, a flow in which the user's mobile operator confirms the request and
your backend polls until the token is ready. On a local or sandbox deployment, a single
request can exchange the consent ID for a token instead. That request is off by default
and answers 404 until the backend runs with
AUTH_SERVER_SANDBOX_EXCHANGE_ENABLED=true, so on a local deployment set it in the backend's.envfirst. -
Set the
resourceparameter to theresourcevalue from the MCP server's metadata document, which ison this portal. Use it exactly as published, with no path and no trailing slash. -
The token response includes
expires_in, which is the token's lifetime in seconds. Request a new token when the current one expires. -
The
verify_phone_numbertool works differently from the other three. It needs a single-use token from the OAuth 2.0 authorization code flow, which starts on the user's own device, and your backend requests a new token for every call.
The Guide has code examples for the token request under LLM Integration (MCP Tools) → Authentication.
Step 4: Connect the agent to the MCP server
-
Point your MCP client at
. The server uses the Streamable HTTP transport. -
Pass the access token from Step 3 to the process that runs your MCP client, for example
through the
NEURALGATE_MCP_TOKENenvironment variable. The client sends it in theAuthorizationheader of every request:
If you use an IDE or desktop MCP client such as Claude Code or Cursor, the configuration looks like this: -
Call
tools/listto see the tools your application can use. The list contains the checks you turned on in Step 1. -
On each tool call, your code adds two arguments:
consentToken, which is the consent token from Step 2, andintentContext, which states the reason for the call. Add both in your code and leave them out of the tool schema that the LLM sees, so the consent token stays out of the model's context. Use theseintentContextvalues:Tool What it checks intentContext verify_ageWhether the user is at least a given age dpv:AgeVerificationverify_sim_swapWhether the number moved to a new SIM recently dpv:FraudPreventionAndDetectionverify_locationWhether the device is inside a given area dpv:DeliveryOfGoodsverify_phone_numberWhether the device uses the given phone number dpv:FraudPreventionAndDetection
Step 5: Handle errors
-
An HTTP
401response with aWWW-Authenticateheader means the access token is missing, expired or invalid. Request a new token as in Step 3. -
Consent problems arrive as a normal tool result with
isError: trueand acodefield. Read thecodefield rather than the message text. -
CONSENT_REQUIREDmeans the user has not given consent yet. Collect consent as in Step 2, request a new access token as in Step 3, and then run the agent again. -
CONSENT_DENIED,CONSENT_EXPIREDandCONSENT_REVOKEDmean the agent should stop and return control to your app. Retrying these calls gives the same result.
Keep credentials safe
- Keep the client ID and client secret on your backend only.
- Give the access token only to the process that runs the MCP client.
- Keep consent tokens on your backend, and add them to tool calls in code. Keep the client secret, the access token and consent tokens out of the LLM's context.
-
Use the OAuth access token for the MCP server. The
ng_API key and the Application Crypto key are for other integrations, and the MCP server rejects them with401.
Other resources
- The Guide (under Resources in the portal) has more detail and code examples on its LLM Integration (MCP Tools) tab, and separate tabs for Getting Started, React, React Native and REST APIs.
- The AI Skills tab in the Guide has a prompt called MCP tools for AI agents that lets a coding assistant such as Claude Code or Cursor carry out Step 4 in your codebase.
- The SDKs page (under Resources) has the React and React Native packages for the consent screen in Step 2. They install from a tarball link on that page, not from the public npm registry.
- The REST APIs tab in the Guide shows how to call the same checks directly from your server, without an AI agent.