Skip to content

MCP Server Security Best Practices for Coding Agents

3 min read

Using Model Context Protocol (MCP) servers with coding agents bridges your local development environment and external tools, databases, or APIs. While this integration expands what your agents can accomplish, it also introduces real security risks. A compromised or poorly configured MCP server can read sensitive files, run unintended shell commands, or leak API keys. This guide covers practical mcp server security best practices to keep your machine and projects safe.

Audit and Restrict File System Access

MCP servers often require paths to operate on your codebase. The primary risk is granting an untrusted server access outside your intended directory, or giving it unrestricted write access to sensitive system paths like ~/.ssh or your global configuration files.

When configuring an MCP server in your environment, explicitly scope file paths to the specific project directory rather than your home directory. If an MCP server tool allows you to pass arguments or query parameters that resolve paths, verify how it sanitizes inputs. Never configure an MCP server with broader read or write permissions than the project requires.

When you run multiple terminals or workflows in an environment like Tidepane, each project should have isolated configurations. If a server only needs to read a single documentation folder, configure it read-only.

Vet Trusted Sources and Examine Code

It is easy to find community-built MCP servers for databases, issue trackers, and cloud platforms. However, running code from unverified GitHub repositories or package registries means you are executing third-party code with your local user permissions.

Before adding a new server:

  • Inspect the source code, especially any network requests, file system operations, or subprocess executions.
  • Check the author's reputation and repository activity.
  • Prefer official servers maintained by the service provider (such as GitHub, Supabase, or Sentry) over community rewrites when available.
  • Run the server in a container or isolated directory if you cannot verify its internals.

If a server requires a local daemon or script execution via Node.js or Python, ensure you understand every dependency it pulls in. A routine npm install might pull down transitive dependencies with malicious code.

Read Permission Prompts and Tool Declarations

Most coding agents and MCP clients prompt you before executing a tool call or allowing an MCP server to access sensitive data. It is common fatigue to click past these prompts, but doing so bypasses your primary defense.

Always read permission prompts carefully. If an agent requests permission to read an environment file (.env) or write to a directory outside the repository, pause and evaluate why the MCP server needs that access. If a tool declaration looks overly broad—such as a database tool that requests full DDL execution privileges when you only need read access—reject the prompt and adjust the server's configuration.

Regularly Remove Unused Servers

Unused MCP servers left in configuration files remain a persistent vector for supply chain risks and silent privilege creep. If an update to an abandoned package introduces a vulnerability, your environment remains exposed even if you stopped using the tool months ago.

Periodically audit your configuration files (such as .mcp.json or your agent's global configuration file). Remove any servers you are no longer actively using for current projects. Keeping a clean configuration ensures that you know precisely what external capabilities your coding agents can access at any given time.

Conclusion

Securing your agent workflow comes down to treating MCP servers with the same caution you apply to third-party binary dependencies. Scope their file access strictly, verify where the code comes from, read permission prompts instead of dismissing them, and purge unused servers from your configs. To manage your active agent workflows securely, see how to see what all your coding agents are doing at once.

Tidepane brings terminals, a browser and your coding agents into one window. See what it does.