MCP security best practices

By AIPx team · Published 2026-10-14 · Updated 2026-10-14

MCP security is the work of protecting the path from an AI host to external tools, accounts and data. The main concerns include prompt injection, unsafe tool execution, credential compromise and excessive access. A secure setup needs controls at the host, gateway, server and upstream service; using a standard protocol alone does not make those boundaries safe.

This guide follows official material checked on October 14, 2026. It describes practical design and review steps rather than certifying any product or claiming that human confirmation detects every attack.

MCP security risks

A malicious instruction can arrive inside legitimate data. Imagine a coding assistant reading an issue that says it must send an environment file to an external address before investigating the bug. The issue content is part of the task’s evidence, not authority to grant a new action. If the host also exposes email or shell tools, the attack can cross from an allowed read into an unrelated operation.

Tool poisoning creates another path. A server’s operation description can contain misleading instructions or conceal behavior. The model relies on descriptions when choosing tools, but the executor should not treat a description as permission to bypass the user’s scope. Review the server and the actual handler behind the name.

Credentials add independent risks. A long-lived token copied into a configuration file can be stolen from the host environment. A remote integration with excessive scopes can perform more than the task needs. If several agents share one credential, attribution and selective revocation also become harder.

ThreatExample pathUseful controlRemaining risk
Prompt injectionRetrieved issue requests unrelated data exportSeparate content from authority; restrict available actionsAllowed reads may still expose sensitive content
Unsafe metadataTool description redirects the modelReview server source and operation contractTrusted servers can have defects
Token theftSecret copied into broad process environmentScoped credentials and restricted storageAuthorized process compromise can still expose access
Excessive scopesAssistant can delete when only search is neededRemove unnecessary tools and upstream rightsA permitted action can still be inappropriate
Local compromiseUnreviewed package executes on the workstationInspect source and process permissionsDependencies and updates need continued review
Remote misuseProxy accepts a token for another audienceValidate the client-facing authorization boundaryCorrect authentication does not validate task intent

The official security guidance discusses confused-deputy behavior, token passthrough, SSRF, state-handle attacks and local compromise. These are separate from model-content problems: an integration can have sound prompt handling while still accepting the wrong token or fetching an unsafe URL.

Local and remote servers trade risks. Local code can access the permissions and environment of its process. Remote code adds a service operator and network boundary. Neither location should be labeled universally safe. Review remote servers and architecture to identify the actual route.

MCP security best practices

Begin with the authorized task. Write down the accounts and operations needed to complete it. Reads deserve review as well as writes: retrieving confidential messages may disclose information even if no upstream object changes. Expose a small useful set instead of every operation offered by the service.

Keep upstream credentials out of model context. The model can propose an operation; the executor should hold the credential needed to perform it. Do not ask the assistant to find tokens in documents or paste them into unrelated tool arguments when authentication fails.

Authenticate the remote client for the intended service and validate audience and issuer as appropriate. Keep that client-facing boundary separate from the upstream API grant. A token valid for an application API should not automatically be accepted as proof that a caller may use the proxy.

Validate more than input shape. A URL can be syntactically valid and still target a protected network resource. A record identifier can be well-formed and belong to a different account. Use account-aware object checks and constrained destinations for tools that access external resources.

Review execution after setup changes. Adding a server, reconnecting an account or upgrading a package can change the available tools and scopes. A previously narrow host can become broader without a change to its system prompt. Treat the catalog as configuration worth inspecting.

Use human review where the implementation supports it, but test that behavior. A proposed write should show the destination and important parameters. Repeated vague approval prompts can train people to click through, so keep review tied to concrete consequences.

AIPx’s modes have a specific limitation. Allow and Confirm are execution hints, and Confirm review depends on the client honoring approval metadata. Hide is enforced server-side and removes the operation from the agent surface. The permissions page should be read with that distinction; Confirm is not a universal gateway approval gate.

Secure integration patterns

For a read-oriented assistant, connect an account with the narrowest available upstream rights and hide unnecessary writes. Give the host clear tool descriptions and inspect the data returned. If the task needs one project, do not assume broad account search is equally appropriate.

For a write-capable assistant, separate proposal from execution where possible. The proposed change should identify the account, object and payload. Validate those values before touching the upstream service. If the client cannot reliably honor review metadata, use stronger server-side restrictions or another execution path for sensitive actions.

For internal tools, constrain the handler’s authority. A bounded operation such as “retrieve deployment status for this service” is easier to reason about than an arbitrary URL fetcher or shell executor. Keep validation close to the action, even when the host has its own policy.

For local servers, inspect installation and runtime permissions. Do not place every credential in the parent process environment simply to make setup convenient. Use a dedicated test account first and confirm which files or network destinations the process actually needs.

For remote servers, inspect the operator and authorization flow. Review MCP OAuth for the client-facing path and agent authentication for the broader credential model. A maintained endpoint can simplify operations, but it does not remove the need to understand who receives your data.

Handle uncertain writes carefully. A timeout after sending a request does not prove that the upstream action failed. Check the destination state or use an operation-specific idempotency mechanism before retrying. Duplicate emails or calendar events can result from an otherwise reasonable recovery attempt.

MCP security tools and vendors

Products cover different parts of the control surface. The following is a documented-scope comparison, not a ranking based on unperformed tests.

OptionDocumented roleWhat to verify for your setup
AIPxPersonal account gateway with tool/account/agent rules and call recordsActual client review behavior, catalog coverage and account destination
ObotOrganizational gateway/control plane with identity and access capabilitiesChosen hosted/self-hosted deployment, policy semantics and records
MintiveEnterprise gateway with role-oriented controls and advertised log exportQuoted configuration, identity integration and operational requirements
Direct official serverNarrow access to the upstream providerOperator trust, scopes, tool behavior and host policy
Custom bounded handlerApplication-owned execution boundaryValidation, secrets, audit and maintenance ownership

AIPx is useful when supported accounts and agent-specific rules meet a developer’s needs. Its integration catalog is smaller than broad integration platforms, and its hosted service adds a trust boundary. It does not promise enterprise SSO, DLP, complete injection detection or compliance certification.

The Obot comparison and MintMCP comparison explain where organizational controls can be the better fit. Evaluate a product against the actor, account and operation you need to protect, rather than treating “gateway” as a complete security claim.

MCP security for teams

Assign an owner to each server and account connection. Record its purpose, allowed users or agents, required operations and credential lifecycle. A connection without an owner is hard to review after a person leaves or a workflow changes.

Keep incident evidence useful and bounded. Call records should help identify the account, operation and outcome. Avoid logging raw tokens or indiscriminately retaining sensitive arguments. Control who can inspect records and decide how long they are needed. The observability guide distinguishes audit data from full traces.

Define a removal procedure before an incident. Disable the affected agent route, revoke the relevant credential, inspect upstream state and preserve enough records to understand the impact. Re-prompting the model alone is not a response to a compromised token or unsafe tool implementation.

Use the OWASP Agentic Applications 2026 resource as a risk framework, not a certification. For wider ownership and governance, read AI agent security. Start with narrow, testable controls and expand the tool surface only when the task and operating responsibility justify it.

Further reading

MCP gateway; what is an MCP server; what is mcp.

FAQ

What are the main MCP security risks?

They include hostile content or tool metadata, unsafe execution, stolen credentials and excessive access. A permitted read can influence a later operation through the host.

How do I secure an MCP server?

Use appropriate caller authentication, narrow upstream credentials, account-aware input validation, restricted operations and useful call records. Review the chosen transport and runtime as well.

Does OAuth prevent prompt injection?

No. OAuth addresses delegated access and authorization boundaries; it does not establish that retrieved text or a model-proposed operation is safe.

Are local MCP servers safer than remote servers?

Neither is universally safer. Local execution adds package and process risk, while remote execution adds operator, network and delegated-access boundaries.

Can per-tool permissions prevent data leaks?

They reduce available operations, but allowed reads and other outbound channels still matter. In AIPx, Hide is enforced; Confirm is a client-dependent approval hint.