sodcalculator

10 Tech How-To

MCP Servers: Connect AI Tools Without Sharing Credentials

Guide 10-39732 · Updated · Step by step

MCP servers let an AI application use tools and data through a defined interface, while credentials can remain in a separate, trusted service instead of being handed to the model or agent. To reduce credential exposure, put authentication and permission checks in the MCP server or a secure proxy, grant only the access required, and keep secrets out of prompts and tool results.

What MCP servers do

The Model Context Protocol (MCP) is an open protocol for connecting AI applications to external capabilities. An MCP server can expose tools, such as searching an issue tracker or creating a calendar event, and resources, such as documents or database records. The AI application acts as the host: it can connect to one or more servers and decide when to offer their capabilities to a model.

MCP standardizes how a client discovers and calls those capabilities; it does not automatically make a connection safe, authenticate every user, or prevent a tool from doing something harmful. A server may run locally as a process or remotely as a service. The deployment and authentication design determine where credentials live and what authority a call receives.

How to connect without exposing credentials

Use an architecture in which the agent requests an action, but a trusted component performs the authenticated operation. For example, an agent can ask an MCP server to find a ticket. The server uses its configured identity to query the ticket system and returns only the permitted fields. The model does not need to see the API key used for that query.

  1. Choose a trusted server. Review its source, maintainer, dependencies, and documented behavior. A server can access whatever its process or service identity permits, so treat it as security-sensitive software.
  2. Keep secrets outside the model context. Store credentials in a secret manager or protected runtime configuration, not in prompts, chat messages, tool descriptions, source control, or logs. Avoid pasting a personal access token into an AI application’s configuration unless the application is explicitly designed to protect it.
  3. Authenticate the server-to-service connection. The MCP server, or a trusted gateway in front of it, should obtain the credential and attach it to the downstream request. For remote connections, use the authentication mechanism supported by the client, server, and service; OAuth-based flows can support user authorization without giving the model the user’s password.
  4. Limit authority. Use a dedicated identity with the minimum scopes, data access, and permitted operations needed. Prefer read-only access if the task only needs reading. Separate identities for different systems or environments when practical.
  5. Approve consequential actions. Require confirmation for actions such as sending messages, changing records, deleting files, or making purchases. Validate tool arguments on the server, not just in the model’s instructions.
  6. Test and monitor. Check what data the server returns, where logs are written, how errors are handled, and whether credentials are redacted. Revoke or rotate a credential if it may have been exposed.

A useful pattern is a narrow tool rather than a general-purpose command channel. “Look up the status of this ticket” gives a server a specific job; an unrestricted shell or generic HTTP tool may allow far broader actions. Tool names and descriptions help a model choose, but they are not security boundaries.

Credential models and trade-offs

There is no single authentication arrangement for every MCP deployment. Choose according to whether the tool acts as an individual user, a shared service, or an administrator, and verify what the chosen client and server actually support.

  • Service credential held by the server: The server uses a narrowly scoped service identity. This is straightforward for shared, automated tasks, but the identity may grant access beyond what a particular user should have. The server needs strong secret storage and user-level authorization where relevant.
  • User authorization through OAuth: A user authorizes access through the service’s sign-in flow, and the server handles the resulting tokens. This can better reflect individual permissions, but tokens still need secure storage, appropriate scopes, expiry handling, and revocation. OAuth does not mean the model receives a password-free or risk-free connection automatically.
  • Credential broker or gateway: A separate trusted component authenticates requests and forwards only allowed operations. This can centralize policy and secret handling, but adds configuration and another component to secure and monitor.

Some local integrations instead read credentials from the user’s existing environment or configuration. That may avoid copying a key into a prompt, but it does not make the server harmless: a process running as the user can potentially access files and services available to that account. Check the process permissions and the server’s behavior.

What the model can still see

Keeping a credential out of the model is important, but it is only one part of protecting an integration. The model may receive tool outputs, and those outputs can contain private records, personal information, or instructions embedded in retrieved content. Limit returned fields, filter data where appropriate, and do not assume that information becomes safe simply because it came from a trusted service.

Also consider prompt injection: a document or web page may contain text that tries to persuade the model to call tools or reveal information. Treat retrieved text as untrusted input. Enforce access checks and operation limits in the server, and require a separate confirmation for sensitive changes. A model’s promise to ignore malicious instructions is not a substitute for these controls.

Use encrypted transport for remote connections and protect the server’s own configuration, logs, and updates. Logs can accidentally capture headers, tokens, query contents, or returned records. Keep logs useful for auditing without recording secrets, restrict access to them, and establish a clear process for revoking credentials.

Common connection problems

If an MCP tool does not connect, first identify which link is failing: the AI client to the MCP server, or the MCP server to the downstream service. A successful connection to the MCP server does not prove that its separate API credential is valid.

  • Authentication rejected: Check the credential’s expiry, required scopes, audience or account, and whether the server is using the intended secret. Do not troubleshoot by pasting the secret into a chat.
  • Tool appears but calls fail: Discovery may work even when downstream permissions are missing. Inspect the server’s error details and service-side access controls without exposing tokens in logs.
  • Local server will not start: Verify the executable or runtime, configuration path, and required environment variables. Use the AI client’s documented connection settings and restart or reconnect after changes.
  • Remote connection fails: Check network reachability, the endpoint, TLS configuration, and the authentication flow expected by both sides. Avoid disabling certificate checks as a quick fix.
  • Unexpected access or output: Disable the integration while investigating, review server permissions and audit records, and revoke credentials if exposure is plausible.

Frequently Asked Questions

Does an MCP server need my API key?
It may need a credential to call the connected service, but the server can hold and use that credential without exposing it to the model. Whether it is safe depends on the server, its runtime permissions, storage, and access controls.

Can an AI agent use MCP without ever seeing my password?
Yes. A server or trusted authentication component can handle sign-in and downstream requests. Keep passwords and tokens out of prompts and model-visible tool results, and check that the client and server do not expose them through configuration or logs.

Is a local MCP server automatically safer than a remote one?
No. Local execution can reduce network exposure, but a local process may have access to the user’s files or credentials. Remote servers introduce network and service-hosting risks. Evaluate permissions, authentication, transport, and operator trust in either case.

Should I use a personal token or a service account?
Use the identity that fits the task and has the least required authority. A service identity can suit shared automation; per-user authorization can better match individual permissions. Avoid broad, long-lived credentials when a narrower or shorter-lived option is available.

What should I do if I accidentally exposed a token?
Revoke it at the issuing service, replace it with a restricted credential if needed, and inspect relevant access logs for unexpected use. Remove the secret from prompts or files where possible, but do not assume deletion alone makes an exposed token safe.

Does MCP itself guarantee that tools are safe?
No. MCP defines a way for clients and servers to communicate. Security depends on implementation, authentication, authorization, the tool’s permissions, and safeguards around the model’s use of tool results and actions.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →