feat: Add HTTP support for local MCP servers #3877
Closed
+241
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Add HTTP support for local MCP servers
Summary
This PR adds support for
http://URLs in MCP server references to enable local MCP server connections during development. Previously, CrewAI only acceptedhttps://URLs for external MCP servers, which prevented developers from using local MCP servers running onhttp://localhostor other local HTTP endpoints.Changes:
validate_mcps()inbase_agent.pyto accepthttp://,https://, andcrewai-amp:URLs_get_mcp_tools_from_string()inagent/core.pyto routehttp://URLs to_get_external_mcp_tools()http://scheme is detected (security awareness for non-TLS connections)http://support for local developmentExample Usage:
Review & Testing Checklist for Human
uv run pytest lib/crewai/tests/mcp/test_http_mcp_support.py -vvto verify all tests passhttp://localhost:PORT/mcpand verify an agent can connect and retrieve toolshttp://URLs, confirm the warning message appears in logs mentioning "local development only" and recommendinghttps://for productionhttps://andcrewai-amp:URLs still work correctlyftp://example.com/mcpand verify the error message lists all three supported schemes (http://,https://,crewai-amp:)Notes
HTTPTransportandMCPToolWrapperalready supported HTTP URLs without validation, so this PR primarily removes the artificial restriction in the validator and routing logichttp://is detected to make developers aware of the non-TLS connection--block-networkconstraint)Link to Devin run: https://app.devin.ai/sessions/28a42c2337524ee78df7d245e28e3ade
Requested by: João (joao@crewai.com)
Fixes #3876