Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Security

MCP Server Behaviour Sandbox That Checks Tools Do What Their Descriptions Claim

Build a sandbox that installs a Model Context Protocol (MCP) server, calls every tool it offers, and records what each call really does: files read, processes started, hosts contacted. It then compares that behaviour with the tool's own description and flags the gap, such as a 'weather' tool that reads your SSH keys. Developers get a behaviour report before they connect an AI agent to a server they found on GitHub or npm.

Difficulty

Advanced

Needs a team, real planning, and a supervisor who knows the area.
Effort

2 semesters · 2 to 3 students

Deliverables

7 to ship

4 optional extras

Suggested stack

Python or TypeScriptMCP Python or TypeScript SDKDocker or gVisor sandboxstrace or eBPF tracing (Tetragon)mitmproxy for network captureA small LLM for argument generation
A suggestion, not a requirement. Swap anything for what you already know.

What you should ship

  • A sandbox runner that installs an MCP server from npm, PyPI or a Git URL into an isolated container with no real secrets
  • Planted canary files (fake SSH keys, fake cloud credentials, fake browser profile) whose access is logged
  • A tool exerciser that lists tools and calls each one with schema-valid arguments, including edge cases
  • Per-tool behaviour traces: files opened, processes spawned, DNS lookups and outbound connections
  • A declared-versus-observed comparison that flags behaviour the description does not explain
  • A report in HTML and JSON with a risk level and the exact evidence for every finding
  • A study of at least 40 public MCP servers with findings checked by hand

If you have time left

  • Re-run the sandbox on every new release and diff behaviour between versions
  • A GitHub Action that blocks adding an MCP server to a project config until its report is reviewed
  • Static scanning of tool descriptions for hidden instructions, combined with the runtime evidence
  • Responsible disclosure write-ups for any real issues found

The problem: installing an MCP server means trusting a stranger's code

The Model Context Protocol lets AI agents such as coding assistants call tools: read a database, open a ticket, search the web. Thousands of MCP servers are now published on GitHub, npm and PyPI, and developers add them to their editor config in seconds. Each server runs on the developer's own machine, with the same access to files, environment variables and the network as the developer.

That is a large trust decision made on the strength of a README. A tool described as "get the weather" can also read ~/.aws/credentials and post it somewhere. Security researchers have shown that tool descriptions themselves can carry hidden instructions to the model (tool poisoning), and that a server can change its tools after the user has approved them. Most of the defences so far look at the text a server shows to the model. Far fewer look at what the server actually does on the machine.

What already exists and the gap

  • MCP-Scan from Invariant Labs inspects MCP client configurations and tool metadata for prompt injection, tool poisoning and changed tool definitions, and can pin tools so changes are noticed.
  • McpSafetyScanner, released with the paper below, uses agents to probe a server and write a security report.
  • General malware sandboxes run binaries and record behaviour, but they do not know how to drive an MCP server through its tools.
  • Package scanners for npm and PyPI look for known malware patterns in install scripts.

The gap is a runtime check built for MCP: drive every tool the way an agent would, record what the process does at the operating system level, and compare that with what the tool says it is for. Text checks miss a tool with an honest description and dishonest code. Behaviour checks catch it.

Inspiration

"MCP Safety Audit: LLMs with the Model Context Protocol Allow Major Security Exploits" by Brandon Radosevich and John T. Halloran (arXiv 2504.03767, 2025) showed leading models being coerced through MCP tools into running malicious code and stealing credentials, and released McpSafetyScanner. Invariant Labs' public proof of concept of tool poisoning in April 2025 showed a single poisoned description exfiltrating private data. This project takes the complementary angle: observe behaviour, not just text.

What you build

  • Developers paste a package name or Git URL and get a behaviour report per tool within minutes.
  • Team leads keep an approved list of MCP servers, each with a report attached, and see what changed in a new version before upgrading.
  • Researchers get a dataset of real MCP server behaviour to study.

The technically interesting part

  • Driving tools without a human. Read each tool's JSON schema and generate valid arguments, then boundary cases: empty strings, long strings, paths like ../../, URLs pointing at a local listener. A small language model can propose realistic values (a city name for a weather tool), but schema-driven generation must work without it.
  • Seeing everything the process does. Trace system calls with strace, or use eBPF through Tetragon for lower overhead, and capture network traffic through a proxy with a planted certificate. Attribute each event to the tool call that caused it using timestamps and process trees, which is harder than it sounds when servers start background workers.
  • Canaries. Plant fake but realistic secrets in the sandbox's home folder and environment. Any read of them by a tool that has no reason to touch them is a strong signal, with very few false alarms.
  • Declared versus observed. Turn each description into expected capabilities (network to an API host, no file access, and so on) with simple rules plus an optional model, then flag behaviour outside that envelope. Keep the reasoning visible so a human can disagree.
  • Evasion. Malicious code may check whether it is in a container or wait before acting. Document which evasion tricks your sandbox catches and which it does not.

How to evaluate it

  • Planted malicious servers: write at least 10 small servers with known bad behaviour (credential reads, hidden network calls, delayed actions) and measure how many your sandbox flags.
  • False alarms: run popular, well-maintained servers and count findings a human judges as harmless.
  • Coverage: share of tools the exerciser could call successfully without manual help.
  • Cost: time and memory per server analysed.

Suggested plan

  • Weeks 1 to 3: learn MCP by building two small servers; run them in a container and trace them with strace.
  • Weeks 4 to 7: sandbox runner, canary files, network capture and the tool exerciser.
  • Weeks 8 to 11: event attribution per tool call and the declared-versus-observed rules.
  • Weeks 12 to 15: planted malicious servers, first evaluation and the HTML report.
  • Second semester: the 40-server study, version diffing, the GitHub Action and the write-up.

Path to a product

Companies adopting AI agents need an approval process for the tools those agents use, much as they vet browser extensions or open source libraries. A hosted registry of behaviour reports for public MCP servers, with private scanning for internal servers, is a credible product. Even as an open source tool, a well argued study of real servers is publishable and a strong portfolio piece for AI security roles.

Scope warning

Never run unknown servers outside the sandbox, and never use real credentials anywhere in the project. Handle only the standard input and output transport first; add HTTP transports later. If you find a real malicious or vulnerable server, report it privately to the maintainer or the registry before publishing.

Learn what you need on Sefism

Get help with this idea

The hard parts are attributing low-level events to the right tool call and keeping false alarms low enough that people read the report. Tauseef can help you scope the sandbox, choose the tracing approach and design the study of public servers. If you are new here, create a free account first.

Ideas and guidance, not finished projects

These are project ideas and scoping guidance, published free for students to use as a starting point. I do not build, write, or sell final-year projects, and I do not complete coursework for anyone. Take an idea, make it yours, and build it.

Not sure this one fits you?

I help students pick an idea that matches their skills and their deadline, then scope it down until it is finishable. Guidance only, never done for you.

Discuss this idea
Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.