MCP — Model Context Protocol
Three transports for connecting to MCP servers:
- ▸MCPServerStdio — local subprocess; ideal for development.
- ▸MCPServerSSE — legacy remote transport via Server-Sent Events.
- ▸MCPServerHTTP — modern streamable HTTP; recommended for production remote servers.
from crewai_tools import MCPServerAdapter
from crewai.mcp import MCPServerHTTP
from crewai.mcp.filters import create_static_tool_filter
server = MCPServerHTTP(url="https://mcp.example.com")
adapter = MCPServerAdapter(server=server)
adapter.with_filter(create_static_tool_filter(["search", "fetch"]))
agent = Agent(role="Research", tools=adapter.tools, ...)
MCP Filtering
Most servers expose more tools than your agent needs. Apply a filter:
- •create_static_tool_filter — fixed allowlist.
- •create_dynamic_tool_filter — predicate-based, context-aware.
MCP Security
Validate inputs aggressively. Defend against command injection (shell/SQL), path traversal (block ../), and schema violations. Always run remote MCP over TLS with bearer auth.
A2A — Agent-to-Agent Protocol
Install with crewai[a2a]. Configure outbound delegation with A2AClientConfig; expose your crew as an A2A server with A2AServerConfig. When you surface the Agent-to-UI extension, call validate_a2ui_message() on untrusted UI envelopes before routing them to a renderer.
A2A Auth Methods
- APIKeyAuth — internal links.
- BearerTokenAuth — OAuth tokens.
- OAuth2ClientCredentials — service-to-service.
- HTTPBasicAuth — legacy.
- EnterpriseTokenAuth — AMP-managed.
Update Transports
Pick how status flows from server to client:
- •StreamingConfig — live token stream.
- •PollingConfig — periodic GETs.
- •PushNotificationConfig — HMAC-signed webhook callbacks.
A2A Events
The runtime emits granular events for every A2A phase — see the Hooks & Events chapter for the full catalog (AgentCardFetched, TransportNegotiated, Conversation*, Delegation*, ServerTask*, Context*, Polling*, PushNotification*).
Notes
Treat remote tools as untrusted code paths
MCP expands capability quickly; pair it with allowlists, argument validation, and outbound network controls so agents cannot pivot into internal admin APIs.
Latency stacks per hop
Each MCP round trip adds tail risk. Cache stable reads, batch calls, and set aggressive timeouts with structured errors returned to the crew.
A2A trust boundaries need explicit identities
Agent-to-agent calls should authenticate like microservices: mTLS or signed tokens, scoped roles, and replay protection on state-changing operations.
Version remote catalogs intentionally
Tool lists that change daily break reproducibility. Pin server revisions in staging and roll forward with changelog review.
CrewAI MCP and A2A FAQ
What is MCP in CrewAI?
Model Context Protocol integrations let agents call external MCP servers for tools and resources with a standard wire format instead of bespoke HTTP wrappers everywhere.
What does A2A mean for CrewAI deployments?
Agent-to-agent configuration covers how separate agent services trust each other, authenticate, and exchange structured messages without sharing one giant prompt context.
How should I filter MCP tools?
Expose the smallest tool surface that satisfies each agent's role, and block high-risk tools in production unless gated by humans or policy engines.
What auth patterns work with CrewAI MCP?
Use short-lived tokens, mTLS, or signed requests depending on your environment, and never embed long-lived secrets in prompts or logs.
Where do observability hooks matter for MCP?
Log tool latency, failures, and payload sizes per server so noisy or misconfigured MCP endpoints are obvious before they impact customers.
See also: DevShelfHub's CrewAI tool review for a product-level comparison, pricing notes, and links back into this tutorial series.