Connecting an MCP server in the application

A successful connection needs compatible endpoint, transport and authentication.

What you will learn

  • Explain: host, client and server
  • Apply the idea in an example: Connecting an MCP server in the application
  • Recognize limitations and verify the exercise outcome

A successful connection needs compatible endpoint, transport and authentication. Then select tools useful to the agent.

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.

The model proposes, the tool executes

Tool calling produces a call request with a name and arguments. The application validates the schema, permissions and limits before execution. The result returns to context for the next step. For example, get_product_stock takes a SKU and returns a quantity; its description should explain that it does not reserve products. Distinguish empty results, validation errors, missing access and timeouts. Valid JSON does not prove the arguments are correct or the action is authorized. For external effects, also consider duplicate execution.

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.

The visual map

Connecting an MCP server in the application 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. Connections: Application MCP endpoint → Transport and authentication; Transport and authentication → MCP client; MCP client → Discover tool schemas; Discover tool schemas → Input / output schema; User request → Agent / LLM; Agent / LLM → MCP tools / RAG; MCP tools / RAG → Tool results; Tool results → Playground tests; Access permissions → Transport and authentication; Input / output schema → Agent / LLM; Tool results → Agent / LLM. M02 · Relationship map Connecting an MCP server in the application Tool / service Application MCP endpoint Decision / control Transport and authentication Decision / control Access permissions Processing MCP client Processing Discover tool schemas Data Input / output schema Input User request AI model / agent Agent / LLM Tool / service MCP tools / RAG Data Tool results Processing Playground tests Main flow Data and context Feedback and return

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

In MCP Servers set identity and URL, choose AUTO or server transport and authentication. Test, inspect tools and attach only get_product_stock to the agent.

Try it yourself

  1. Connect a read-only test server and verify a valid-SKU call.
  2. Record the input, source and expected outcome before running the experiment. Use only the fictional data in the example.
  3. Follow the diagram stages. At every step record what information is received and produced; do not confuse intermediate output with the final outcome.
  4. Repeat after removing necessary information or making the input ambiguous. Check whether the system clarifies, stops or invents an answer.
  5. Compare with the explained solution. Keep the configuration, date, result and an explanation for differences. Change one thing and retest.

An explained solution

The connection is checked, the tool is discovered and an allowed call succeeds. 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

stdio is a general concept, not an implied remote-form option. 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.

Who executes a call proposed by the model?

The application or host service after validation. The model does not automatically gain unrestricted access.

What outcome should this exercise produce?

The connection is checked, the tool is discovered and an allowed call succeeds.

Words to remember

  • MCP server: A service exposing capabilities through Model Context Protocol.
  • Tool calling: A structured request to use an external capability.
  • Autorizare / Authorization: Checking the right to access an operation or resource.

Sources and your next step

To prepare: M01 — What is an MCP server?