sourcemod-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sourcemod-mcpshow me the current players on the server"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SourceMod MCP Server
A Model Context Protocol server that gives Claude general-purpose, programmatic control over a local TF2 / SourceMod game server: query live state, run commands, compile and hot-load plugins, stream telemetry, debug runtime errors, and write throwaway one-off scripts — all through the full SourceMod native API rather than by scraping console text.
Architecture
Two processes on the same machine, connected by a persistent local TCP socket:
┌─────────────┐ stdio ┌──────────────────┐ local TCP ┌──────────────────────┐
│ Claude │◄──────────►│ MCP server │◄──────────────►│ Bridge plugin │
│ (client) │ (MCP) │ (TypeScript) │ JSON frames │ (SourcePawn, in │
└─────────────┘ │ │ │ the gameserver) │
│ • tool surface │ │ • intent dispatch │
│ • spcomp / files │ │ • event push │
│ • RCON fallback │ │ • full SM native API │
└──────────────────┘ └──────────────────────┘MCP server (
src/, Node + TypeScript, ESM): exposes the tools to Claude over stdio, runs the local socket server the plugin connects to, invokesspcomp, edits files under whitelisted roots, and falls back to RCON when the bridge is down.Bridge plugin (
plugin/, SourcePawn + sm-ext-socket + sm-ripext): runs inside the gameserver, receives JSON intents, executes them with the full SourceMod API, and pushes game events back.
The MCP server is the TCP server; the plugin is the client and reconnects every 5 s if the link drops.
stdout is owned by the MCP transport — all server diagnostics go to stderr.
Related MCP server: Minecraft RCON MCP Server
Wire protocol
Raw local TCP carrying length-prefixed JSON frames:
┌────────────────────────┬─────────────────────────────────┐
│ 4-byte length (BE u32) │ UTF-8 JSON payload (that many) │
└────────────────────────┴─────────────────────────────────┘Length prefix is a big-endian unsigned 32-bit byte count of the JSON that follows.
Max frame size is 8 MiB (
MAX_FRAME_BYTES); larger frames are a protocol error.Frames may be split across TCP reads or coalesced; both sides decode incrementally.
Message shape
{
"id": "uuid-or-correlation-id", // correlates an intent with its result
"type": "intent" | "result" | "event",
"action": "console", // the verb; "" on results
"payload": { /* action-specific */ }
}intent— MCP → plugin. A request to do something. The plugin replies with aresultcarrying the sameid.result— plugin → MCP.payloadis{ ok: boolean, data?: unknown, error?: string }.event— plugin → MCP, unsolicited. Telemetry (connects, deaths, chat, round/map changes) and structured errors (action: "sm_error"). No reply.
Intents are correlated by id: the MCP server keeps a pending-intent registry and resolves the matching
promise when the result arrives (or rejects on timeout).
MCP tools
30 tools, grouped by concern.
Control
Tool | Purpose |
| The general control primitive. Send any typed action to the plugin and get a structured result. The |
| Report whether the plugin is connected, and ping it to confirm the link is responsive. |
Telemetry
Tool | Purpose |
| Read the live in-memory event buffer (recent connects, deaths, chat, round/map changes, errors). |
| Structured snapshot of players/teams/map/bot counts via SourceMod natives (not text parsing). |
Build & deploy
Tool | Purpose |
| Invoke |
| Copy a compiled |
| Lifecycle via the bridge (RCON fallback). |
| Run a raw console command over RCON, no plugin required (gated). |
Files
Tool | Purpose |
| Scoped to whitelisted roots (scripting, cfg, plugins, scratch) via the path guard. |
Config (.cfg)
Tool | Purpose |
| List |
| Read or fully rewrite a |
| Read or set a single cvar in place, preserving comments and other settings. |
| Apply a |
Debugging
Tool | Purpose |
| Structured SourcePawn errors (plugin, file, line, native, message) from the plugin's error hook. |
| Query the persistent on-disk event log, filterable by time/action. |
| Toggle the plugin's structured error capture. |
| Toggle persisting the event stream to disk. |
| Trigger a named in-game scenario to recreate a bug deterministically. |
| Read internal state a target plugin opted in to expose. |
Scratch scripting (ephemeral, zero-trace)
Tool | Purpose |
| Compile + hot-load a one-off micro-plugin from source. Returns diagnostics on failure so Claude can auto-correct. |
| List currently loaded scratch scripts. |
| Unload + delete scratch scripts (removes every file). |
| Copy a scratch script's source out into a persistent standalone plugin. |
Zero-trace guarantee: the scratch dir is wiped on startup (the real backstop against crash orphans) and on shutdown; kills remove every file from both scratch and plugins dirs; failed compiles leave nothing on disk. Promotion to a real plugin is the only way scratch content persists, and it is always explicit.
Bridge plugin actions
Actions the plugin's dispatcher (MCP_HandleAction) understands, invoked via send_intent or a typed tool:
Action | Payload | Result data |
|
|
|
|
| command output |
|
| players/teams/map/bot snapshot |
|
| lifecycle result |
|
|
|
|
|
|
|
| scenario effect |
|
| exposed state |
Events pushed by the plugin include player_connect, player_disconnect, player_death, player_say,
round_start, round_end, map_start, and sm_error (structured runtime errors).
Safety
MCP has no interactive mid-call prompt, so destructive actions use a two-step confirmation gate:
A destructive console/RCON command called without
confirm: truereturns a preview ({ requiresConfirmation: true, reason, hint }) and does not run.Re-issue the same tool with
confirm: trueto execute.
Commands classified as destructive (in src/safety.ts): quit/exit/restart, map/changelevel,
kickall, kick/ban/addip, exec, mp_restartgame/mp_restartround, and anything that rewrites server
auth (rcon_password/sv_password). Read-only and benign commands run straight through. This applies to both
rcon_exec and the console action of send_intent.
Additional safety layers: all filesystem tools are confined to whitelisted roots via a resolve-and-confine path
guard (blocks ../ traversal); the RCON password lives only in the environment, never in code; and all inputs
are validated with zod schemas at the tool boundary.
Setup
Prerequisites
Node.js ≥ 20 (developed on v24), npm.
A TF2 / SourceMod server you control locally.
spcomp(bundled with SourceMod) for compiling plugins.The
sm-ext-socketextension andsm-ripextinstalled in the gameserver.
1. Install and build the MCP server
npm install
npm run build2. Configure
Copy config.example.json to config.json and fill in the paths and credentials:
Key | Purpose |
| Local socket the plugin connects to (default |
| Root of the game server install. |
| SourceMod |
| SourceMod |
| Server |
| Isolated dir for ephemeral scratch scripts (default |
| Path to the |
| RCON fallback credentials. |
The config file is resolved in order: an explicit path passed as the first CLI argument
(node dist/index.js C:/path/config.json), then the SM_MCP_CONFIG env var, then config.json next to the
project root. Any field may be omitted; documented defaults apply.
3. Compile and load the bridge plugin
Compile plugin/scripting/mcp_bridge.sp with spcomp (its includes are under
plugin/scripting/include/mcp_bridge/), deploy the .smx into the gameserver's plugins dir, and load it. The
plugin connects to the MCP socket on load and reconnects automatically. Its host/port are set via the
mcp_bridge_host / mcp_bridge_port ConVars; check the link with the mcp_bridge_status admin command.
4. Register the MCP server with Claude
Point your MCP client at the built server (stdio transport):
{
"mcpServers": {
"sourcemod": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "/path/to/sourcemod-mcp"
}
}
}Or register it from the CLI:
claude mcp add sourcemod --scope user -- node /path/to/sourcemod-mcp/dist/index.jsDevelopment
npm run typecheck # tsc --noEmit
npm run build # compile to dist/
npm run dev # watch mode
npm start # run the built serverProject layout
src/
index.ts entry point: boots socket + tools, wires shutdown
config.ts env → typed config
protocol.ts frame encode/decode, message types
socket-server.ts the local TCP server + pending-intent registry
safety.ts destructive-command classifier + confirmation gate
compiler.ts spcomp invocation + diagnostic parsing
rcon.ts RCON fallback
path-guard.ts resolve-and-confine within whitelisted roots
scratch-manager.ts ephemeral scratch lifecycle + zero-trace cleanup
event-buffer.ts live in-memory event ring buffer
debug-store.ts error ring buffer + on-disk event log
logger.ts stderr structured logging
tools/ the MCP tool modules (one per concern)
plugin/
scripting/mcp_bridge.sp main bridge plugin
scripting/include/mcp_bridge/*.inc protocol, dispatch, telemetry, debugThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceEnables dynamic loading, hot-reloading, and orchestration of MCP servers without restarting Claude Code, allowing programmatic tool calling and workflow automation across multiple servers.Last updated2
- AlicenseAqualityDmaintenanceConnects AI agents to Minecraft servers via RCON to execute commands, monitor logs, and perform read-only SQLite database queries. It is specifically designed to facilitate AI-assisted plugin development, live debugging, and automated testing workflows.Last updated611MIT
- AlicenseAqualityDmaintenanceConnects Claude directly to Godot 4 projects to read and manipulate scenes, nodes, scripts, and assets within the editor. It enables real-time scene tree management, script editing, and resource configuration through a local Node.js bridge and GDScript plugin.Last updated16313MIT
- Alicense-qualityBmaintenanceExposes Steam Web API tools as MCP resources for Claude Code, Claude Desktop, and Gemini CLI, enabling profile lookups, game searches, achievement tracking, and more.Last updated381MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal E…
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Hosted Amazon Seller and Vendor MCP server for Claude, ChatGPT, Cursor, Codex, Gemini, Copilot.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/vicentefelipechile/sourcemod-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server