Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

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 accepted https:// URLs for external MCP servers, which prevented developers from using local MCP servers running on http://localhost or other local HTTP endpoints.

Changes:

  • Updated validate_mcps() in base_agent.py to accept http://, https://, and crewai-amp: URLs
  • Updated _get_mcp_tools_from_string() in agent/core.py to route http:// URLs to _get_external_mcp_tools()
  • Added warning log when http:// scheme is detected (security awareness for non-TLS connections)
  • Updated field descriptions and docstrings to document http:// support for local development
  • Added comprehensive test suite covering validation, routing, config support, fragment filtering, and warning logs

Example Usage:

agent = Agent(
    role="Data Collector",
    goal="Collect data using MCP tools",
    backstory="...",
    mcps=["http://localhost:7365/mcp#diff_general_info"]  # Now works!
)

Review & Testing Checklist for Human

  • Run the new test suite - I couldn't run tests locally due to environment issues. Please run uv run pytest lib/crewai/tests/mcp/test_http_mcp_support.py -vv to verify all tests pass
  • Test with a real local MCP server - Spin up a local MCP server on http://localhost:PORT/mcp and verify an agent can connect and retrieve tools
  • Verify warning log appears - When using http:// URLs, confirm the warning message appears in logs mentioning "local development only" and recommending https:// for production
  • Test backward compatibility - Verify existing https:// and crewai-amp: URLs still work correctly
  • Check error messages - Try an invalid URL like ftp://example.com/mcp and verify the error message lists all three supported schemes (http://, https://, crewai-amp:)

Notes

  • The underlying HTTPTransport and MCPToolWrapper already supported HTTP URLs without validation, so this PR primarily removes the artificial restriction in the validator and routing logic
  • Security warning is logged at the WARNING level when http:// is detected to make developers aware of the non-TLS connection
  • All tests use mocking to avoid network calls (required for CI's --block-network constraint)

Link to Devin run: https://app.devin.ai/sessions/28a42c2337524ee78df7d245e28e3ade
Requested by: João (joao@crewai.com)

Fixes #3876

- Update validate_mcps() to accept http://, https://, and crewai-amp: URLs
- Update _get_mcp_tools_from_string() to route http:// URLs to _get_external_mcp_tools()
- Add warning log when http:// scheme is detected (security awareness)
- Update mcps field description to mention http:// support for local development
- Update HTTPTransport and MCPServerHTTP docstrings with http:// examples
- Add comprehensive tests for HTTP MCP support

This enables developers to use local MCP servers running on http://localhost
or other local HTTP endpoints during development, while maintaining security
awareness by logging warnings when http:// is used.

Fixes #3876

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 3 commits November 10, 2025 15:10
The project uses a custom Logger that emits via _logger.log() rather than
Python's standard logging module, so caplog won't capture the warnings.
Updated tests to monkeypatch agent._logger.log instead of using caplog.

Co-Authored-By: João <joao@crewai.com>
The test was patching 'crewai.agent.core.MCPToolWrapper' but the import
happens inside _get_external_mcp_tools as 'from crewai.tools.mcp_tool_wrapper
import MCPToolWrapper'. Updated to patch the correct import path to ensure
the test works when it actually runs.

Co-Authored-By: João <joao@crewai.com>
1. Fragment filtering test: Added proper assertion for MCPToolWrapper call
   and verified the mock tool is returned in the result list.

2. Logger patching tests: Changed from patching instance method to patching
   class method to avoid Pydantic's __delattr__ restriction. This prevents
   AttributeError when the patch context manager tries to restore the
   original attribute.

Co-Authored-By: João <joao@crewai.com>
@lorenzejay
Copy link
Collaborator

addressed here - #3850

@lorenzejay lorenzejay closed this Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add http support for local mcp servers

2 participants