Skip to main content

Consuming MCP from an Agent

An AI Agent in WSO2 Integrator can use any MCP server as a tool source. Add the server once; the agent picks up every tool the server advertises (or only the ones you select) and treats them exactly like local function tools.

Adding an MCP server to an agent

On the agent canvas, click + Add ToolUse MCP Server. The Add MCP Server panel opens:

The Add MCP Server panel. Tools to Include is set to All. Advanced Configurations expanded showing: Info (name and version), HTTP Version with Select / Expression toggle, HTTP1 Settings, HTTP2 Settings, Timeout (default 30 seconds), Forwarded.

FieldWhat it does
Server URLThe MCP endpoint, for example http://localhost:9090/mcp.
Tools to IncludeAll to expose every tool the server advertises, or a list of names to expose only some.
Info → nameThe MCP client identifier sent to the server.
Info → versionA version string for your client.
HTTP VersionHTTP/2_0 for modern Streamable HTTP servers; HTTP/1_1 for older ones.
HTTP1 / HTTP2 SettingsProtocol tuning such as keep-alive, header sizes, and frame sizes.
TimeoutPer-call timeout. Default 30 s; increase for slow tools.
ForwardedWhether to send Forwarded / X-Forwarded-For when sitting behind a proxy.

After Save, every selected tool from the MCP server appears in the agent's tool list. They are indistinguishable to the agent's LLM from any other tool.

Filtering tools

When an MCP server exposes many tools, do not pull them all in. Pick the few you actually want.

In the Edit MCP Server panel, set Tools to Include to Selected and check the tools the agent should have access to. The panel queries the server and lists every tool it advertises.

The Edit MCP Server panel with Tools to Include set to Selected, showing the Available Tools list with searchProducts and submitReturnRequest checked and getOrderStatus unchecked.

Why it matters:

  • Tool selection accuracy. LLMs choose better with fewer options.
  • Prompt size. Every tool's name, description, and parameter schema is sent on every call. Filtering trims the prompt.
  • Cost. Smaller prompts cost less.
  • Security. Don't expose the agent to mutation tools you didn't design for.

Combining MCP servers, local tools, and toolkits

The agent's tools array accepts any combination of:

  • Function tools marked @ai:AgentTool.
  • Custom toolkit classes (your own *ai:BaseToolKit implementations).
  • ai:McpToolKit instances for one or more remote MCP servers.
final ai:McpToolKit slackMcp = check new ("http://localhost:9092/mcp");
final ai:McpToolKit calendarMcp = check new ("http://localhost:9093/mcp");

final ai:Agent supportAgent = check new (
systemPrompt = {
role: "Support Assistant",
instructions: "Use CRM tools for customer info, Slack for notifications, " +
"and Calendar for scheduling follow-ups."
},
tools = [
getCustomerDetails, // local function tool
createSupportTicket, // local function tool
slackMcp, // MCP toolkit
calendarMcp // another MCP toolkit
],
model = check ai:getDefaultModelProvider()
);

Local tools and MCP tools are completely interchangeable from the agent's perspective. The LLM sees one unified tool list.

Production tips

  • configurable for endpoints. Hard-coding MCP URLs makes environments harder to manage. Expose the URL as a configurable variable so it can be set per environment without changing source code.

  • Run MCP servers close to the agent. MCP calls are on the agent's hot path. Network latency between agent and server directly increases user-perceived response time.

  • Authenticate the connection. If the MCP server is yours, put auth in front. If it's external, follow the vendor's auth scheme. Most use OAuth or bearer tokens passed via headers.

  • Watch token bills. Every tool the toolkit advertises is included in every reasoning step's prompt. A 50-tool MCP server, unfiltered, is a real prompt-token cost.

What's Next