MCP server
Give Claude, ChatGPT or Cursor 26 tools so an agent can analyse a brand, write the script, generate the video and track it to completion — on your behalf, with guard rails on what it may spend.
Model Context Protocol is the open standard for handing an AI assistant a set of tools. This server wraps the Market4Me API, so anything you can do over REST an agent can do in conversation.
Install
You need an API key first — dashboard, Settings → API & integrations.
Claude Desktop & Claude Code
Add this to your MCP config (claude_desktop_config.json, or .mcp.json in a project for Claude Code) and restart.
{
"mcpServers": {
"market4me": {
"command": "npx",
"args": ["-y", "@market4me/mcp-server"],
"env": {
"MARKET4ME_API_KEY": "m4m_live_YOUR_KEY",
"MARKET4ME_MAX_CREDITS_PER_CALL": "250"
}
}
}
}Then just ask: "analyse acmecoffee.com and make me a 10-second product video". It will chain the tools itself.
Cursor, Windsurf, Zed & other stdio clients
Same command, same environment variables:
MARKET4ME_API_KEY=m4m_live_YOUR_KEY npx -y @market4me/mcp-serverChatGPT & OpenAI
OpenAI's custom GPTs and function calling consume OpenAPI rather than MCP — so point them at the spec instead. Same API, same key. In the GPT builder add an Action, import this URL, and set authentication to API Key → Bearer.
https://gateway.market4me.ai//api/v1/openapi.jsonConfiguration
| Variable | Default | What it does |
|---|---|---|
MARKET4ME_API_KEY | — | Required for stdio. Your key. |
MARKET4ME_BASE_URL | https://gateway.market4me.ai/ | Point at a different environment. |
MARKET4ME_MAX_CREDITS_PER_CALL | 250 | Price above which a generation needs your explicit approval. |
Spending safety
An agent driving this server is spending real money on your behalf. Three things protect you, and they compose.
1. The confirmation gate
Anything priced above MARKET4ME_MAX_CREDITS_PER_CALL is refused once, with the exact price. The agent has to show you that number and get a yes, then call again with confirm_credits set to it. No large spend happens without the price having been said out loud and agreed to.
NEEDS CONFIRMATION — this video costs 350 credits, above the 250-credit
threshold this server confirms at.
Tell the user it will cost 350 credits and ask them to approve it.
If they approve, call this tool again with exactly the same arguments
plus confirm_credits: 350.It is deliberately a gate rather than a hard ceiling. A 5-second 1080p video costs around 350 credits, so any limit low enough to be meaningful would block the most basic call outright, leaving the agent stuck until you edit a config file and restart your client. The predictable result of that design is people setting the limit to 999999 and forgetting it. A gate you can pass deliberately is safer than a wall you are forced to remove.
2. Per-key spending ceilings
Set a lifetime credit cap when you create the key. Enforced server-side, so it holds even if someone edits the MCP config — and it holds under concurrency, so a runaway loop cannot slip past it.
3. Free-first tool design
estimate_cost, generate_content and draft_ugc_script are free or near-free, and their descriptions tell the model to draft and price before it renders. Failed generations are refunded automatically.
Give an autonomous agent its own key with a modest ceiling and only the scopes it needs. Revoking one key then costs you nothing else.
Tool reference
26 tools. "free" costs no credits; "cheap" is typically a credit or two; "credits" scales with duration and quality.
Account
| Tool | Cost | What it does |
|---|---|---|
get_account | free | Plan, credit balance, brands and what is gated. The first call an agent should make. |
get_credits | free | Balance plus recent transactions. |
estimate_cost | free | Price any generation without running it, and check affordability. |
Brands
| Tool | Cost | What it does |
|---|---|---|
list_brands | free | Every brand with its analysis status. |
create_brand | free | Create a brand and analyse its website into a brand brain. |
get_brand | free | One brand — used to poll until analysis completes. |
analyze_brand | free | Re-crawl a website and rebuild the brain. |
get_brand_intelligence | free | Tone, audience, products, USP, key messages, content pillars. |
Generation
| Tool | Cost | What it does |
|---|---|---|
generate_video | credits | Prompt → a finished video clip, returned synchronously. |
generate_image | credits | Generate, edit or face-swap an image. |
generate_speech | credits | Text → voiceover audio. |
generate_avatar | credits | A portrait plus words → a lip-synced spokesperson video. |
generate_content | cheap | Scripts, hooks, carousels and captions, on-brand. |
create_brand_video | credits | The full pipeline — script, scenes, voiceover, captions. Async. |
create_film | credits | One idea → a multi-scene narrated film. Async, subscription-gated. |
draft_ugc_script | free | A creator-style ad script to iterate on before spending. |
render_ugc | credits | Render an approved UGC script into a finished ad. |
transcribe_video | cheap | Transcribe a video, or burn subtitles into it. |
Jobs
| Tool | Cost | What it does |
|---|---|---|
wait_for_job | free | Block until an async job finishes. Use instead of polling. |
get_job | free | One status snapshot. |
list_jobs | free | Recent jobs — how to find a render that outlived its request. |
Assets
| Tool | Cost | What it does |
|---|---|---|
list_assets | free | Everything the account has produced, newest first. |
upload_media | free | Presigned URL to bring your own image, video or audio in. |
list_models | free | Available quality/price tiers. |
Webhooks
| Tool | Cost | What it does |
|---|---|---|
create_webhook | free | Register a callback endpoint. Returns the signing secret once. |
list_webhooks | free | Registered endpoints and their delivery health. |
How they fit together
create_brand(website_url) → builds the brand brain (30–90s)
└─ get_brand until complete
├─ generate_content → script / caption drafts (cheap)
├─ generate_image → a still (cheap)
│ └─ generate_video(image_url) → animate that still
├─ generate_speech → voiceover audio
│ └─ generate_avatar(audio_url) → a person saying it
├─ create_brand_video → full pipeline (async) ─┐
└─ create_film → multi-scene film (async) ┴─ wait_for_jobEverything after create_brand is automatically on-brand — the agent never has to re-describe the business.
Resources & prompts
Beyond tools, the server exposes resources (context a client can attach to a conversation) and prompts (guided workflows a user can pick from a menu).
| Resource | Contents |
|---|---|
market4me://account | Plan, credit balance, brands. |
market4me://brands/{id}/intelligence | The brand brain — attach it and ask for ad angles directly. |
market4me://openapi | The full REST contract. |
| Prompt | Walks through |
|---|---|
new_brand_setup | Onboarding a business from its URL and reviewing what was learned. |
make_marketing_video | Draft → price → confirm → render, in that order. |
campaign_from_website | Analyse, propose a costed asset plan, wait for approval. |
Remote / hosted
The same binary runs as an HTTP server for clients that connect over the network. Each client sends its own key, so one deployment serves many customers and no credential lives on the server.
npx -y @market4me/mcp-server --http --port 8787
# clients connect to: http://your-host:8787/mcp
# with header: Authorization: Bearer m4m_live_...- Sessions are per-client and isolated — two customers connected at once never share state.
- Idle sessions are reaped after 30 minutes.
GET /healthreports version and active session count.
Put it behind TLS. The API key travels in a header, and over plain HTTP on an untrusted network that is a credential in the clear.
Troubleshooting
| Symptom | Cause & fix |
|---|---|
| The server does not appear in Claude | Config JSON is invalid, or the client was not restarted. Check for a trailing comma, then fully quit and reopen — reloading the window is not enough. |
| Exits immediately | No API key. Set MARKET4ME_API_KEY. The server writes the reason to stderr; your client's MCP log will show it. |
| Every tool returns an auth error | The key is wrong, revoked or expired. Verify it with curl https://gateway.market4me.ai//api/v1/me. |
| A tool says NEEDS CONFIRMATION | Working as designed — see Spending safety. Approve the price, then let the agent retry with confirm_credits. |
| subscription_required on create_film | Director needs an active subscription. Buying credits will not unlock it. Use create_brand_video instead. |
| A generation timed out | Do not retry — you would pay twice. The render is still running; use list_jobs or list_assets to collect it. |
Prefer to call it directly? The REST reference documents every endpoint the tools wrap.