MCP security and troubleshooting
MCP can fail at networking, authentication, discovery or execution.
What you will learn
- Explain: host, client and server
- Apply the idea in an example: MCP security and troubleshooting
- Recognize limitations and verify the exercise outcome
MCP can fail at networking, authentication, discovery or execution. Separate these stages to avoid random changes.
These steps refer to features identified in the application code. This material has not been validated on a live instance; check the documentation and the options in your version.
How it works, step by step
Host, client and server
MCP is a protocol connecting AI applications to external capabilities. The host provides the experience, the client manages the connection, and the server exposes tools, resources or prompts according to support. Tools execute operations; resources provide addressable content; prompts provide templates. Not every server implements all three. Transport carries messages, authentication identifies callers, and authorization controls access. Check protocol revision and supported extensions at both ends. Compatibility cannot be inferred from an “MCP” label alone.
Check access before use
Permissions must be enforced by servers and the data layer. Do not let the model decide whether a user may see a document. Filter sources before they enter context, not after generating the answer. Use minimal-access credentials, keep them out of prompts, screenshots and browser code, and rotate exposed keys. A widget domain allowlist does not replace API authentication. Authentication identifies you; authorization determines the operations and data you can use. Test denied access too.
Errors need explicit paths
A timeout differs from a permission error. Retry only transient errors, with bounded attempts and increasing delays. An operation with side effects may execute before its response is lost; retrying without an idempotency key can duplicate the effect. Streaming shows progress but does not guarantee completion. Checkpoints may allow failed stages to resume within runtime limits. Store the run identifier, stage, duration and error while removing secrets from logs. Measure slow paths as well as averages.
The visual map
Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. On smaller screens, scroll horizontally to follow the entire diagram.
A complete example
A wrong key gives access denial. A wrong endpoint may return an HTML page. A tool timeout does not prove a discovery-schema problem.
Try it yourself
- Test wrong key, wrong endpoint and invalid arguments using demonstration data.
- Record the input, source and expected outcome before running the experiment. Use only the fictional data in the example.
- Follow the diagram stages. At every step record what information is received and produced; do not confuse intermediate output with the final outcome.
- Repeat after removing necessary information or making the input ambiguous. Check whether the system clarifies, stops or invents an answer.
- Compare with the explained solution. Keep the configuration, date, result and an explanation for differences. Change one thing and retest.
An explained solution
Classify the error and correct configuration without copying secrets into logs or screenshots. A successful exercise lets you show the connection between input, stages and outcome. When information is missing, a cautious answer is more useful than invented details. Compare more than style: check conditions, sources and operations too.
When it helps and what can go wrong
A connected server may still have an unavailable tool. Choose this approach when it improves a measured need. Keep a simple baseline and compare outcomes using identical inputs. One successful example does not establish reliability in every situation.
Check your understanding
Does a server with tools automatically offer resources and prompts?
No. Capabilities are optional and must be discovered and checked.
Why is removing a private source after answering too late?
The data has already entered model context and can be disclosed.
What outcome should this exercise produce?
Classify the error and correct configuration without copying secrets into logs or screenshots.
Words to remember
- MCP server: A service exposing capabilities through Model Context Protocol.
- Autorizare / Authorization: Checking the right to access an operation or resource.
- Idempotency: Controlled repetition without duplicating an effect.
Sources and your next step
To prepare: M02 — Connecting an MCP server in the application