Guide
Test Moderation Policies from Claude and Cursor with the Vettly MCP Server
Most moderation bugs are policy bugs, not code bugs. The integration is usually a few lines: send the text, read action, store the decision ID. The part that goes wrong is the policy. A harassment threshold is too low and flags friendly trash talk. A rule is missing, so scam links get through. Someone sets block where flag was intended.
Those bugs are hard to catch because a policy is tested differently from code. You don't unit-test a threshold. You run real messages through it and look at what comes back. That loop usually means switching to a dashboard, pasting examples one at a time and keeping notes. The Vettly MCP server moves the loop into the place you already work: Claude Code, Claude Desktop or Cursor.
This guide covers what the server exposes, how to install it in each client, three workflows that make it worth installing, and the things it does not do.
What the server exposes
@vettly/mcp (version 0.1.11 on npm, registry name io.github.code-with-brian/vettly) is a stdio MCP server. It wraps the Vettly API and exposes three kinds of things: tools, resources and prompts.
Tools
moderate_content. Inputs:content(required),policyId(required),contentType:text,imageorvideo, defaulttext. Runs a real check against a saved policy. ReturnsdecisionId,safe,flagged,action,categories,provider,latencyandcost. For images and video,contentis the URL.validate_policy. Input:yamlContent(required). Validates policy YAML without saving it. Returns whether it is valid, plus any errors.list_policies. Input:status:activeorall, defaultactive. Lists the policies in your account.get_usage_stats. Input:days: 1 to 365, default 30. Request counts, costs and outcomes for the period.get_recent_decisions. Inputs:limit: 1 to 50, default 10, plus optionalflagged,policyIdandcontentTypefilters. Recent decisions, filtered.
All five are marked read-only in their MCP annotations. None of them changes your account. moderate_content is handled exactly like a production check, nothing more.
Resources
vettly://policiesreturns the policy list as JSON.vettly://policies/{policyId}returns one policy's YAML.
Resources are useful when you want the model to read a policy before it reasons about results, so it can see the actual thresholds instead of guessing.
Prompts
moderate-content-guidewalks the model through listing policies, checking content and reading results.write-policytakes an optionalplatformargument (for example "marketplace" or "kids app") and sets up a policy-drafting session that ends withvalidate_policy.review-flagged-contenttakes an optionalpolicyIdand sets up a review of recent flagged decisions.
In Claude Code, MCP prompts show up as slash commands. Other clients surface them differently, and some don't surface them at all. In that case, ask for the same workflow in plain language.
Install and configure
The package publishes one binary, vettly-mcp. The documented way to run it is npx -y @vettly/mcp, so nothing has to be installed globally. It reads two environment variables:
VETTLY_API_KEY: your API key. Required to test your own policies.VETTLY_API_URL: optional. Defaults tohttps://api.vettly.dev.
Get a key from the API keys page in the dashboard. If you start the server without VETTLY_API_KEY, version 0.1.11 logs that it is starting in demo mode, limited to 10 requests a day. That is enough to check the wiring, but not enough to test your own policies, so set a key.
Claude Code
Add the server with claude mcp add. Everything after -- is the command Claude Code runs:
claude mcp add vettly -e VETTLY_API_KEY=vettly_live_xxx -- npx -y @vettly/mcp
That uses the default local scope, which applies only to you in the current project. Use --scope user to make it available in every project. If you want the whole team to get the server from the repo, use --scope project. That writes an .mcp.json file at the project root, and Claude Code expands environment variables in it, so the key stays out of git:
{"mcpServers": {"vettly": {"command": "npx","args": ["-y", "@vettly/mcp"],"env": {"VETTLY_API_KEY": "${VETTLY_API_KEY}"}}}}
Run /mcp inside Claude Code to confirm the server is connected and the five tools are listed.
Claude Desktop
Edit claude_desktop_config.json. On macOS it is at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows it is at %APPDATA%\Claude\claude_desktop_config.json.
{"mcpServers": {"vettly": {"command": "npx","args": ["-y", "@vettly/mcp"],"env": {"VETTLY_API_KEY": "vettly_live_xxx"}}}}
Restart Claude Desktop after saving the file. If the server fails to start, the usual cause is that Desktop can't find npx on its PATH. Point command at the absolute path that which npx prints.
Cursor
Cursor reads the same mcpServers shape. To keep the server to one project, put it in .cursor/mcp.json in the project. To make it available everywhere, put it in ~/.cursor/mcp.json:
{"mcpServers": {"vettly": {"command": "npx","args": ["-y", "@vettly/mcp"],"env": {"VETTLY_API_KEY": "vettly_live_xxx"}}}}
If the project file is committed, keep the real key out of it. Cursor resolves ${env:NAME} in env values, so you can set "VETTLY_API_KEY": "${env:VETTLY_API_KEY}" and keep the key in your shell environment. The server's status and tool list are shown under MCP in Cursor's settings.
Workflow 1: draft a policy and validate it
Start with the write-policy prompt and give it your platform:
Use the write-policy prompt for a secondhand marketplace. Listings and buyer–seller messages. We care about scams, harassment and illegal items. Mild profanity is fine.
The model drafts YAML and then calls validate_policy on it. Expect the first draft to fail. That's the point of the loop. The validator checks against the real policy schema:
- Each policy needs a
name, aversionand a list ofrules. - Each rule needs a
category, athresholdfrom 0 to 1, anactionand aprovider. - Categories come from a fixed set:
hate_speech,harassment,violence,self_harm,sexual,spam,profanity,scamandillegal.
The prompt's built-in template is only a sketch. It uses some category names that aren't in that set and leaves out provider, so the validator is what keeps the draft honest. After a round or two you end up with something like this:
name: marketplace-messagesversion: "1"rules:- category: scamthreshold: 0.6provider: openai_gptaction: block- category: illegalthreshold: 0.5provider: openai_gptaction: block- category: harassmentthreshold: 0.8provider: openai_gptaction: blockbands:- gte: 0.5action: flag- category: hate_speechthreshold: 0.5provider: openai_gptaction: block- category: profanitythreshold: 0.95provider: openai_gptaction: flag
The bands entry on harassment sends the 0.5 to 0.8 range to review instead of making it a hard cliff. The validator also enforces that every band's gte is below the rule's threshold. The policy guide covers bands, compound conditions and the jev provider for text rules if you're on a plan that includes it.
validate_policy only checks structure. It doesn't save anything. When the YAML passes, save it as a policy from the dashboard or the API. The MCP server has no tool that writes policies.
Workflow 2: run sample messages against the saved policy
Once the policy has an ID, give the model a batch of real-shaped messages. Include the borderline ones that started the conversation:
Run each of these through moderate_content with policyId marketplace-messages and give me a table of message, action and the top triggered category with its score:
- "Is this still available? Can pick up Saturday."
- "Pay with gift cards and I'll ship today, no PayPal."
- "lol this price is a joke, you're dreaming"
- "Send the deposit to my cousin's account, I'm out of the country"
- "damn that's a nice bike"
The model calls moderate_content once per message and summarizes. The raw response for each call looks like this:
{"decisionId": "dec_abc123","safe": false,"flagged": true,"action": "block","categories": [{ "category": "scam", "score": 0.91, "triggered": true }],"provider": "openai_gpt","latency": 412,"cost": 0.001}
This is where testing from the editor pays off. Say message 3 comes back flagged for harassment at 0.55. You can read the band you just wrote, decide whether that's the review volume you want, change the threshold in the YAML, revalidate, save and rerun the same five messages. Ask the model to keep the table and show the difference between runs. That's a policy regression test you can rerun in one prompt.
Two practical notes:
- Put the samples in the repo. A
moderation-samples.mdfile next to your policy YAML lets you say "run the samples file against marketplace-messages" and get the same set every time. Claude Code and Cursor can both read the file directly. - Images and video work the same way. Set
contentTypetoimageorvideoand pass a URL ascontent. Use URLs the API can reach. A localhost URL won't work.
Workflow 3: inspect decisions after a change ships
After the policy is live, the other three tools become the feedback loop. The review-flagged-content prompt with a policyId sets up this sequence:
get_recent_decisionswithflagged: trueand the policy ID- The model groups the decisions by category and score
- The model suggests one of three outcomes for each pattern: approve, confirm, or adjust the threshold
get_usage_statsshows whether flag volume moved after the change
A useful prompt for this:
Since we lowered the harassment band to 0.5 yesterday, show me the last 50 flagged decisions on marketplace-messages. Which ones would a human reviewer approve? Read vettly://policies/marketplace-messages first so you know the current thresholds.
Telling the model to read the policy resource first matters. Without it, the model guesses at thresholds from the scores. With it, the model can say which rule fired and how far over the line the score was.
Why test policies in the editor
Three reasons, all practical.
Policy and code change together. A new feature, such as DMs, listing comments or profile bios, usually needs a new policy or a stricter variant of an existing one. If the feature branch, the policy YAML and the test messages live in the same session, the person who knows the feature writes the policy. The alternative is a ticket to whoever owns the dashboard. The policies-as-code post covers keeping that YAML in version control.
Examples beat thresholds. Nobody can say whether 0.6 or 0.7 is the right harassment threshold for a marketplace. Anyone can look at twenty real messages and say which ones should have gone to review. The MCP loop turns that judgment into a threshold quickly.
Tests go through the real path. Each moderate_content call is handled exactly like a production check and returns a decisionId. What you see in the editor is what your app will get.
Limits
These are worth knowing before you build a workflow around the server.
- No dry runs.
moderate_contentis a real check. It calls the provider and is handled exactly like a production check, including counting toward your usage. The REST API has a separatePOST /v1/check/dry-runendpoint that evaluates a policy against mock scores without calling a provider, and it can take an unsaved policy as inline YAML. The MCP server doesn't expose it. If you want threshold logic tests with no provider calls, call it directly. See the REST reference.
curl -X POST https://api.vettly.dev/v1/check/dry-run \-H "Authorization: Bearer $VETTLY_API_KEY" \-H "Content-Type: application/json" \-d '{"content": "dry-run","policyId": "moderate","policy": "name: test\nversion: \"1\"\nrules:\n - category: harassment\n threshold: 0.5\n provider: openai_gpt\n action: block\n","mockScores": { "harassment": 0.9 }}'
- No writes. The server can't create, update or delete policies. That's deliberate, because a chat session shouldn't be able to change what your production traffic is checked against. It does mean every workflow has a manual save step.
- No single-decision lookup. There's no tool that fetches one decision by ID.
get_recent_decisionsreturns the most recent decisions, up to 50. - Filters run after the fetch.
get_recent_decisionsfetches the latestlimitdecisions and then appliesflagged,policyIdandcontentTypein the server. Asking for 10 flagged decisions returns the flagged decisions among the last 10. If your traffic is mostly clean, setlimitto 50. - The model can misread results. The tools return JSON. Summaries and tables are the model's interpretation. For anything you're going to act on, ask for the decision IDs alongside the summary and spot-check a few.
- The key sits in a local config file. Use a key scoped to a test project where you can. Don't commit config files with live keys.
Where this fits
The MCP server is for the people writing and tuning policies. It doesn't replace the integration in your app. Production traffic should go through your backend with the SDK or REST API. The Python guide and the React Native guide cover that side. If your product is itself an agent, runtime guardrails for AI agents covers authorizing actions rather than text.
To get started, create a key from the dashboard, add the server to your client with one of the configs above, and run the write-policy prompt for your platform. If you'd rather try policies before installing anything, the playground runs the same decision engine in the browser. Full tool reference: MCP integration docs.
Frequently asked questions
Which tools does the Vettly MCP server expose?
Five: moderate_content, validate_policy, list_policies, get_usage_stats and get_recent_decisions. It also exposes two read-only resources (vettly://policies and vettly://policies/{policyId}) and three prompts: moderate-content-guide, write-policy and review-flagged-content.
Can the MCP server create or change policies?
No. It can read policies and validate policy YAML, but it cannot save, edit or delete them. Save a policy from the Vettly dashboard or the API, then test it from your editor by its policy ID.
Do moderate_content calls count against my quota?
Yes. moderate_content calls the same check endpoint your production code uses, so each call is handled exactly like a production check and returns a decision ID. It is not a dry run.
What happens if I don't set VETTLY_API_KEY?
Version 0.1.11 starts in a demo mode limited to 10 requests a day and logs that to stderr. Set your own key to test your own policies.
Does it work with editors other than Claude and Cursor?
It is a standard stdio MCP server, so any client that can launch a local MCP server with a command, arguments and environment variables can run it.