L2 · 09 · Using & Configuring MCP Servers
Level 1 explained what MCP is and built a toy server. This page is the practitioner's guide: when an MCP server is worth adding, how to find trustworthy ones, how to configure them in your IDE and CLI agents (with secrets done right), Metals MCP for Scala in depth, and how to troubleshoot.
By the end of this page you can
- Decide between an MCP server, a CLI command the agent runs, or nothing.
- Evaluate an MCP server's trustworthiness before installing it.
- Configure stdio and remote servers in VS Code and CLI agents, with secrets kept out of git.
- Set up and use Metals MCP effectively on a Scala project.
- Keep toolsets small, approvals sensible, and fix common failures.
Do you even need an MCP server?
| Option | Best when | Example |
|---|---|---|
| Nothing extra | Built-in tools (read/edit files, run shell) already cover it | sbt test, git diff, rg |
| CLI via shell | A good CLI exists and the agent can run it. Simple, transparent, scriptable. | gh pr view, psql -c, kubectl get |
| MCP server | You need structured tools, auth flows (OAuth), use outside a terminal (chat apps, IDE chat), fine-grained approvals, or rich language intelligence | Metals (compiler-backed Scala tools), issue trackers, docs search, browser automation, Xcode |
Finding servers and judging trust
Places to look: the official MCP Registry (registry.modelcontextprotocol.io, a public catalogue of server
metadata), the vendor of the system you want to connect (official servers are best), your IDE's marketplace or MCP gallery,
and well-known open-source projects.
- Publisher: is it from the system's vendor or a reputable org? Name-squatting exists.
- Source available and maintained: recent commits, issues answered, a clear licence.
- Permissions: what can its tools do? Read-only modes? Scoped tokens?
- Tool descriptions: read them, since manipulative instructions hidden there are an attack ("tool poisoning").
- Pinned versions: install a specific version rather than "latest" so it can't change under you.
- Data flow: for remote servers, where does your data go, and is it allowed by your company's policy?
Configuration recipes
VS Code (workspace: .vscode/mcp.json)
{
"inputs": [
{ "id": "dbUrl", "type": "promptString", "description": "Read-only dev database URL", "password": true }
],
"servers": {
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@playwright/mcp@<pinned-version>"]
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
},
"orders-db": {
"type": "stdio",
"command": "<trusted-postgres-mcp-server>",
"args": ["--read-only"],
"env": { "DATABASE_URL": "${input:dbUrl}" }
}
}
}
inputsprompt you once for secrets and store them securely, so the file never contains them.- Remote servers that support OAuth open a browser sign-in. The host stores the token.
- User-level config (your profile) is for personal servers. Workspace config is for the team. Commands in the Command Palette start with "MCP:" (add, list, start/stop, show output).
CLI agents
# stdio server (local process) claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@<pinned-version> codex mcp add playwright -- npx -y @playwright/mcp@<pinned-version> # remote server (HTTP) claude mcp add --transport http github https://api.githubcopilot.com/mcp/ # inspect claude mcp list codex mcp list
CLI agents also store servers in config files (user-level and/or project-level). Project-level files can be committed when they contain no secrets. Pass secrets through environment variables.
Other hosts
- JetBrains IDEs: the AI settings include an MCP section to add servers (same fields: name, command/URL, env), and JetBrains IDEs can expose IDE tools to external agents.
- Xcode: acts mainly as a server: enable "Allow external agents to use Xcode tools" and connect agents via
xcrun mcpbridge(Level 1 page 06). - Chat desktop apps: usually an
mcpServersJSON block or a connectors UI.
Metals MCP for Scala, in depth
Metals already gives agents compiler diagnostics (the red squiggles) in editors that surface them. The MCP server goes further and lets agents actively ask the Scala tooling.
| Tool category (names vary by version) | What the agent gains |
|---|---|
| Compile file / module / whole project | Fast, incremental feedback without running a full sbt compile |
| Run tests (suite or single test) | Targeted verification |
| Inspect a symbol (members, signatures) | Real APIs instead of hallucinated methods |
| Get docs for a symbol | Scaladoc for libraries in your classpath, at your exact versions |
| Find usages / search symbols by name or type | Accurate impact analysis for refactors |
| Import build, format, and other helpers | Keeps the workspace in a good state |
- VS Code: set
"metals.startMcpServer": true(and enable MCP/agent mode). Metals logs a line like "Metals MCP server started on port …" and can write the MCP config for supported editors. - Other editors / CLI agents: point the agent at the URL Metals prints, or use the standalone
metals-mcplauncher (install with Coursier:cs install metals-mcp) with your workspace path. - Teach the agent to use it. Add this to
AGENTS.md:
## Scala tooling - Use the Metals MCP tools to inspect symbols and read docs before using an unfamiliar API. - After editing, compile the changed module with the Metals compile tool; fix all errors before running tests. - Prefer the Metals test tool for single suites; run `sbt test` only for the final check.
sbt runs
in agent loops.Useful server categories
| Category | Typical uses | Safety note |
|---|---|---|
| Code hosting (GitHub, GitLab…) | Read issues/PRs, review comments, CI status | Scope tokens to specific repos; review write tools |
| Language tooling (Metals, Xcode) | Compile, inspect, test | Local, low risk |
| Databases | Inspect schemas, run read queries for debugging | Read-only user, dev data only, never production |
| Docs / web fetch | Current library docs and changelogs | Fetched pages can contain prompt injections |
| Browser automation (e.g. Playwright MCP) | Reproduce UI bugs, test flows, take screenshots | Use test accounts; isolate from real logins |
| Issue trackers, chat, docs wikis | Pull ticket context, update status | Approve outbound/write actions |
| Observability (logs, metrics) | Investigate incidents | Logs contain personal data; redact; read-only |
Keep toolsets small
Every enabled tool's name, description and schema is sent to the model on every request. Twenty servers with 300 tools cost tokens, slow responses and confuse tool choice.
- Enable servers per workspace or per task, not globally "just in case".
- Disable individual tools you don't need (most hosts have a tool picker).
- Give custom agents their own toolsets (page 08). The reviewer doesn't need the browser.
- Keep approval on for writes, deletes and anything that sends data out.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Server fails to start | Command not on the PATH the IDE sees (GUI apps often have a different PATH than your shell) | Use an absolute path to the executable; restart the IDE after installing |
| Starts, but no tools listed | Handshake/protocol error, or wrong transport (stdio vs HTTP) | Check the server output/logs; test with the MCP Inspector |
| Metals MCP missing | Setting off, build not imported, port changed | Enable setting, import build, re-check the port in Metals logs |
| 401/403 from remote server | Expired token, missing scopes | Re-authenticate; check token scopes |
| Agent ignores the tool | Vague description, too many tools, or the instruction isn't there | Fewer tools; add guidance to AGENTS.md; name the tool in the prompt once |
| Calls time out | Slow backend or large results | Narrow the query; use pagination; raise timeout if the host allows |
npx @modelcontextprotocol/inspector <command> <args...> # e.g. npx @modelcontextprotocol/inspector uv run word_tools.py
- On a Scala project in VS Code, enable Metals MCP. Ask the agent: "Inspect
OrderServicewith the Metals tools and list its public methods with signatures." Confirm a Metals tool was called. - Add Playwright MCP (pinned version) and ask the agent to open a local web page and describe what's broken.
- Write
.vscode/mcp.jsonwith one secret viainputs. Verify no secret ends up in git (git diff). - Look up one server in the MCP Registry and go through the trust checklist for it.
Key takeaways
- Use built-ins and CLIs first. Add MCP servers when the agent would otherwise guess, or when non-terminal hosts need tools.
- Vet servers: publisher, source, permissions, descriptions, pinned version, data flow.
- Keep secrets out of config files (inputs, env vars, OAuth). Commit only secret-free workspace config.
- Metals MCP gives agents compiler-backed Scala intelligence. Tell the agent to use it in AGENTS.md.
- Small toolsets, approvals for writes, and the Inspector for debugging.