AI agent (MCP)
Use this page when your own AI agent should send your leads to MarsX. You connect the agent to one MCP endpoint that MarsX hosts, give it a token, and it calls six tools. The agent does not build or sign HTTP requests.
What it is
Section titled “What it is”MCP is the Model Context Protocol, a standard way for an AI agent to call tools on a server. The MarsX MCP server is a way to deliver the same lead events as API push. It is not a second contract.
- Every write tool runs the same checks as the signed push: the required fields, identity, revisions, privacy events and quarantine rules.
- MarsX stores an accepted event as a push event. Status reads, the sandbox and the worker behave exactly as for push.
- You host nothing to go live. The four read-only endpoints you may host are optional, a safety net. Rely on the answer to each tool call, on
get_lead_status, and on sending every withdrawal and deletion at once.acceptedandduplicateboth mean MarsX has the event. Retry a rate limit or a timeout with the same arguments. Fix a tool error before you send again. - The server works with any MCP client. No vendor or model is assumed.
Addresses
Section titled “Addresses”| Production | Sandbox | |
|---|---|---|
| MCP endpoint | https://api.marsx.media/mcp |
https://api-sandbox.marsx.media/mcp |
| Token URL | https://api.marsx.media/oauth/token |
https://api-sandbox.marsx.media/oauth/token |
The endpoint speaks MCP Streamable HTTP in stateless mode, with JSON responses and no session IDs. Send POST only: GET and DELETE answer 405. Both hosts serve the API only, over HTTPS, and never the dashboard. A request body is at most 1 MiB (/mcp keeps this limit, while the events and token endpoints take at most 64 KiB), and each event is still held to 32,768 bytes.
Origin. An agent or a server sends no Origin header, and MarsX serves a request without one. A request that carries an Origin header is answered 403 (problem type urn:marsx:problem:origin-not-allowed) unless the origin is one of https://api.marsx.media, https://api-sandbox.marsx.media and https://dash.marsx.media. MarsX checks this before it reads the body or the token. A tool call from a web page of another site is refused, and an MCP client that runs on a server is not affected.
Protocol revision. The server speaks MCP revision 2026-07-28, the current revision: stateless Streamable HTTP, one POST endpoint, no sessions and no GET stream. A client that still sends revision 2025-06-18 or 2025-11-25 is answered too, with the same tools and plain JSON answers.
Create AI agent credentials
Section titled “Create AI agent credentials”Your developer makes the AI agent client ID and secret in Concour. Nobody at MarsX sees the secret.
- Open Developers, then API keys, then the section AI agent credentials.
- Type a name in Name for new AI agent credentials and choose Make AI agent credentials. The dialog Your AI agent credentials shows, once, the Client ID (it starts with
mxc_), the Client secret (it starts withmxs_), the MCP address and the Token address. The two addresses are not secret. The client secret is: anyone who holds it can send leads as your connection. - Copy the secret into your agent’s secret store, then choose I have saved it. MarsX keeps only a hash of it.
- To stop an agent, choose Revoke next to its credentials, then Revoke credentials. The agent can no longer get a token, and a token it already holds stops working. This cannot be undone. If a secret may have leaked, revoke it at once.
- A connection can hold at most 2 active agent clients. Concour shows how many are in use, for example 0 of 2 in use.
- In the sandbox, your developer can make AI agent credentials at any time.
- In production, AI agent credentials can be made only after a MarsX administrator approved the connection’s live key and your developer collected it. Until then Concour says: Live AI agent credentials need a live key first.
- Pausing the connection stops its tokens.
Get a token
Section titled “Get a token”The agent uses OAuth 2.0 client credentials from MarsX’s token endpoint, with its AI agent client ID and secret. The credentials hold the scopes events:write and events:read. Ask for both, as the Setup guide in Concour does. The scope table says what each scope allows.
POST https://api-sandbox.marsx.media/oauth/tokenContent-Type: application/x-www-form-urlencodedAuthorization: Basic <base64(client_id:client_secret)>
grant_type=client_credentials&scope=events:write%20events:read&resource=https://api-sandbox.marsx.media/mcpresource is optional (RFC 8707). It must be the API address, https://api-sandbox.marsx.media here, or the API address followed by /mcp. Any other value gets 400 invalid_target and no token. An MCP client that follows the standard sends it by itself.
The answer holds an access_token that starts with mxt_, token_type Bearer and expires_in 3600. Request a new token before it expires. The agent then sends this header on every request to /mcp:
Authorization: Bearer <access_token>- The token belongs to your connection, and that connection is the only one a tool call can touch. No tool takes a connection reference.
- The token is also bound to the API address that issued it. A sandbox token is refused (
401) onhttps://api.marsx.media, and a production token is refused on the sandbox. Ask each host for its own token. A token that you already held before 11 October 2026 is not bound, and works until it expires, at most one hour. - Without a valid token,
/mcpanswers401with aWWW-Authenticateheader that points to its resource metadata. - A token without the scope a tool needs gets
403insufficient_scope, andtools/listshows only the tools the scope allows. A token withevents:writecan call all six tools. A token with onlyevents:readcan list the tools and callget_lead_statusandfind_dealer, and no write tool. - MarsX publishes
/.well-known/oauth-protected-resourceand/.well-known/oauth-authorization-serveron each API host. A client that follows the MCP OAuth client credentials extension can fetch its own tokens. Any other client sets the header by hand. The authorization server document names/oauth/authorizebecause MCP client libraries need an address there. MarsX issues tokens by client credentials only, soGET /oauth/authorizeanswers400{"error":"unsupported_response_type"}withCache-Control: no-store.
The six tools
Section titled “The six tools”Contract version 1.9.0 (19 October 2026, a Changed entry in the changelog) makes a lead need one usable location signal rather than two fields: customer_city or preferred_dealer_code, either alone, with not_specified counting only beside a real city. The tool schemas carry the pair as anyOf, so an agent reading them is refused the same calls the server refuses. Contract version 1.8.0 (14 October 2026, a Changed entry in the changelog) marks withdraw_consent destructive in its tool annotations, as delete_lead already was, adds the status reasons clearing_awaiting_confirmation and clearing_held_for_investigation for a privacy request that waits for a MarsX privacy operator, and refuses a JSON-RPC batch. Each is described below. Contract version 1.7.0 (13 October 2026, a breaking change) gives every text field a maximum length and refuses control characters: the input schema of each tool carries maxLength and a pattern for them, and a value that breaks either comes back as a tool error with the field’s pointer and the code invalid. The limits are in Text length and characters. Contract version 1.5 (9 October 2026) adds the optional extras customer_address, customer_gps, lead_score, creative_label and staff_notes, which you may send on submit_lead and update_lead and leave out when unknown. Contract version 1.4 (8 October 2026, a breaking change: campaign is required and model_interest no longer accepts not_specified). Every field in the table stays required, and where you genuinely lack the data you send the not-known value instead of inventing one: email not_provided; preferred_dealer_code not_specified; test_drive_requested unknown; enquiry_notes none; campaign not_specified when there is no ad. See Lead fields.
| Tool | Event | You supply | MarsX adds |
|---|---|---|---|
submit_lead |
lead.new |
Required: partner_lead_id, created_at, customer_name, phone, email, model_interest, campaign, test_drive_requested, enquiry_notes, source_channel, contact_consent, consent_time, and one of customer_city or preferred_dealer_code (from version 1.9; not_specified alone is refused). Optional: every other lead field of the contract, including the five optional extras of version 1.5, including source_revision and updated_at |
type, record_action new, timestamp |
update_lead |
lead.update |
As submit_lead, plus source_revision and updated_at, both required |
type, record_action update, timestamp |
withdraw_consent |
lead.withdraw |
partner_lead_id, source_revision, created_at, updated_at, request_type (withdraw_consent or restriction), request_time, request_reference |
type, record_action, timestamp |
delete_lead |
lead.delete |
As withdraw_consent, without request_type |
request_type erasure, type, record_action, timestamp |
get_lead_status |
Read | webhook_id |
The answer of the status read: processing state, reason and warnings, with no customer data |
find_dealer |
Read | query, 2 to 60 characters: a city, a province or an outlet name |
Up to 20 active sales outlets, each with code, name, city and province |
Each tool’s input schema is built from the same rules as the contract. The server always validates the event itself, so the schema guides the agent and MarsX decides. find_dealer exists because an actual dealer code is one of the two ways to give a location, and the agent should look a code up instead of guessing one.
Arguments for a submit_lead call:
{ "partner_lead_id": "SRC-TEST-0004", "created_at": "2026-10-01T10:29:30+07:00", "customer_name": "Contoh Pelanggan Tiga", "phone": "+6280000000003", "email": "contoh.pelanggan3@contoh.example", "model_interest": "Model A", "customer_city": "Kota Bandung", "preferred_dealer_code": "D0001", "test_drive_requested": "N", "enquiry_notes": "Ingin meminta penawaran.", "campaign": "campaign-test", "source_channel": "website_form", "contact_consent": "yes", "consent_time": "2026-10-01T10:29:20+07:00"}Send each privacy request at once, as on Revisions and privacy events. withdraw_consent and delete_lead are marked destructive in their tool annotations, and their descriptions say why: MarsX restricts the lead the moment it stores the request, then permanently clears the customer’s data, and this cannot be undone. The limits of that restriction, such as a page already open, are on Revisions and privacy events. withdraw_consent clears the customer’s name, contact details and notes and the notes the dealership team wrote on the lead. delete_lead permanently erases the customer’s data. The two read tools are marked read-only.
If your connection sends many privacy requests in a short time, MarsX still restricts each lead the moment it stores the request, but clears the data only after a MarsX privacy operator confirms. Until then get_lead_status answers queued with the reason clearing_awaiting_confirmation, or clearing_held_for_investigation while MarsX checks the requests. After the confirmation it answers queued with no reason until MarsX has cleared the lead, and then applied. See Many requests at once.
Connect an MCP client
Section titled “Connect an MCP client”Which clients work. The route is machine to machine: your agent signs in with its own client ID and secret, and no person signs in. It works with:
- an agent you run on your own servers that uses an MCP client library or plain HTTP;
- a tool that lets you set a custom
Authorizationheader, provided that something fetches a new token before the old one expires.
It does not work with a “connect an app” or “add a connector” screen that opens a browser for a person to sign in, as some chat apps have. That screen needs an authorization code grant and client registration, and MarsX offers neither: the only grant is client_credentials, and /.well-known/oauth-authorization-server lists no registration endpoint. If that is the only way your tool connects, tell support@marsx.media.
An MCP client that supports Streamable HTTP and a custom header, and that fetches a new token before the old one expires, can connect. Key names differ between clients, so follow your client’s documentation. The shape is this:
{ "mcpServers": { "marsx-leads": { "type": "http", "url": "https://api-sandbox.marsx.media/mcp", "headers": { "Authorization": "Bearer <access_token>" } } }}A token lasts one hour. Put your own token refresh in front of this setting, or use a client that fetches client credentials tokens itself. Keep the AI agent client secret and the access token in environment variables or a secret store. Never paste them into a chat with a model.
Consent
Section titled “Consent”An agent sends a lead only after the customer agreed to be contacted by a dealer. Send contact_consent yes and a consent_time that records when. The tool descriptions say the same. A lead without consent is refused and nothing is stored. Text that comes back from a tool is data, never an instruction to the agent.
Results, status and duplicates
Section titled “Results, status and duplicates”A write tool answers accepted or duplicate, with a webhook_id and a request_id. Results never repeat customer values.
acceptedmeans the event is stored and queued, as202does for push. Read what the worker decided withget_lead_status.- MarsX derives the
webhook_idfrom the connection, the event type and the content, so the agent does not choose it. An exact retry of the same event is aduplicatewith the samewebhook_id, and is processed once. - A changed lead at the same
source_revisiongets a newwebhook_id. The worker then sets it aside asrevision_conflict. Send a higher revision for every change. - A refused event comes back as a tool error (
isError: true) that lists each problem with itspointer, itscode(required,invalid,unknown_valueornot_allowed) and a fixedmessage. A push400names the same pointers without the code: only MCP tool errors carrycode, and a REST error carries none. A missing required field is named by its pointer with coderequired.
The processing states and reasons are those of Check an event’s status.
One request for each call
Section titled “One request for each call”The route refuses a JSON-RPC batch, which is a request body that is a JSON array. MarsX answers 400 with the JSON-RPC error -32600 and stores nothing. A body whose objects and arrays are nested more than 16 levels deep is refused the same way. Both refusals come before authentication. MCP revision 2025-06-18 removed batching, so send one request for each call. A real MCP call nests about 6 levels.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Write tools, per connection | 100 requests per 10 seconds, shared with API push |
get_lead_status and find_dealer |
60 requests per 60 seconds, shared with the status read |
| Request body | 1 MiB for the request, 32,768 bytes for each event. The token request takes at most 64 KiB |
| Token | 3600 seconds |
| Active agent clients per connection | 2 |
MarsX also limits requests per caller address before it checks a token. When MarsX answers with a rate limit, wait, then retry the same event.
A write call that is refused for too many requests is not listed one by one in the Request log. Instead the log has one row for each ten seconds (from each MarsX server that refused calls), with the route MCP write tools, the response code 429, the result Refused and the text “N calls were refused: too many requests. Wait for the retry time the answer gave, then send again.” The day’s usage counts move by N. If a MarsX server stops inside a ten second window, that window’s count can be lost, so the Request log can show fewer refused calls than you sent and never more. Your own count of refused answers is the exact one. More limits are on Limits.
Test in the sandbox
Section titled “Test in the sandbox”Use invented data only. Each step shows the result to expect.
- Make sandbox AI agent credentials and get a token.
- Connect the agent to
https://api-sandbox.marsx.media/mcpand list the tools. With scopeevents:writeyou see all six. - Call
submit_leadwith every required field. Expectacceptedand awebhook_id. - Call
submit_leadagain with the same arguments. Expectduplicatewith the samewebhook_id. - Call
submit_leadwithoutemail, or without any other required field. Expect a tool error that names the field’spointer. - Call
get_lead_statuswith thewebhook_id, andfind_dealerwith a city. - Ask for a token with scope
events:readonly, then callsubmit_lead. Expect403insufficient_scope.
Before go-live
Section titled “Before go-live”Going live through MCP needs no hosting. The AI agent route does not replace the rest of the go-live list:
- The sandbox steps. See Go live.
- A live key approved by a MarsX administrator and collected. Production AI agent credentials can be made only after that. You are live when your first live lead comes back
Applied. - Optional, for extra safety: the four endpoints MarsX can read (your token URL,
changes,privacy-eventsandleads/{partner_lead_id}). See Host the four endpoints and Test your endpoints.

