Sub topic 13
Choosing Servers and Keeping Context Lean
This chapter assumes you can edit a client's mcpServers configuration and know the difference between tools, resources and prompts. It covers how to decide which servers to install and how to stop them from crowding out your actual work.
Why every server has a cost
A connected server is not free. When a session starts, the client runs tools/list and sends each tool's name, description and input schema to the model. The model has to read all of it on every request, whether or not it uses the tool.
That cost has three parts:
- Context space. Tool definitions use tokens that could hold code, logs or conversation history.
- Selection accuracy. With many similar tools, the model is more likely to pick the wrong one or pass the wrong arguments.
- Attack surface. Every server is more code that runs on your machine or handles your data, and more text that can carry prompt injection.
Output also counts. A tool that returns a 5,000-line file listing or a full database dump fills the context window in a single call.
Decision criteria
Before adding a server, ask these questions in order.
- Does the assistant already do this? Most coding assistants can read files and run shell commands. A filesystem server that duplicates this adds tools without adding ability.
- Is a command-line tool enough? If the assistant can run
git,ghorpsql, a shell call may do the job with no extra definitions. - Does the task need live data or authenticated access? Issue trackers, databases, browsers and internal APIs are good reasons for a server.
- Who maintains it? Prefer servers from the vendor of the service or from a maintained, widely used project. Check the last commit date and open issues.
- What can it do? A read-only server is safer than one that can write or delete. Choose the narrowest scope that works.
The primitive matters too. If a capability is better offered as a resource or a prompt, a server that exposes only tools may force the model to make extra calls to get the same data.
Practical ways to keep context lean
Install per project
Put server entries in a project-level configuration where your assistant supports it, instead of in a global file. A database server belongs in the project that uses the database.
Limit scope at launch
Restrict what a server can reach through its arguments. The filesystem server takes the directories it may access:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
}
}
}Disable unused tools
Many assistants let you turn off individual tools or whole servers. Check your assistant's settings for an allow list or a disable option. Keep only the tools you use.
Control output size
When you write or choose a server, look for pagination, result limits and filters. Ask for "the last 20 log lines" rather than "the log".
Measure it
Most assistants show context usage. Start a fresh session with no task, note the usage, then add one server and compare. The difference is that server's fixed cost.
A quick comparison
| Option | Fixed context cost | Setup effort | Good for |
|---|---|---|---|
| Shell command the assistant already runs | None | None | Well-known CLIs such as `git` |
| Small, focused MCP server | Low | Low | One service with a few tools |
| Large, many-tool MCP server | High | Low | Rarely worth it unless you use most of its tools |
| Custom server you write | You choose | Higher | Internal systems, exact control |
Exercise
Exercise
Your assistant can already run shell commands. You are considering a GitHub MCP server that exposes about 40 tools, but you only need to list and read pull requests. Name two approaches that keep context lean, and say which you would try first.
Show answer
Approach one is to use the gh command-line tool through the shell, which adds no tool definitions. Approach two is to install the server but disable every tool except the pull request read tools, or choose a smaller server limited to read-only pull request access. Try gh first, because it has no fixed context cost and no new code to trust. Move to the server only if you need something the CLI cannot do, such as structured results the model can use more reliably.
Exercise
You add a server and the assistant starts choosing the wrong tool for simple tasks. What do you check first, and how do you confirm your guess?
Show answer
Check how many tools the new server added, and whether their names and descriptions overlap with tools you already have. Confirm by comparing context usage and behavior in a fresh session with and without the server, then disable the overlapping tools or remove the server.