Skip to content

[FEATURE] Add http support for local mcp servers #3876

@erwanDLA

Description

@erwanDLA

Feature Area

Integration with external tools

Is your feature request related to a an existing bug? Please link it here.

Feature Request: HTTP Support for Local MCP Servers

Summary

Add support for http:// URLs in MCP server references to enable local MCP server connections. Currently, CrewAI only supports https:// URLs for external MCP servers, which prevents developers from using local MCP servers running on http://localhost or other local HTTP endpoints.

Use Case

When developing with CrewAI and MCP (Model Context Protocol), developers often run local MCP servers for:

  • Local development and testing
  • Internal tooling and services
  • Development environments without SSL certificates
  • Localhost-based MCP servers (e.g., http://localhost:7365/mcp)

Currently, these local servers cannot be used with CrewAI agents because the library only accepts https:// URLs.

Current Behavior

  1. Validation: The validate_mcps() method in base_agent.py has inconsistent behavior:

    • It accepts http:// URLs in the validation check
    • But the error message incorrectly states only https:// is supported
    • This creates confusion and inconsistent behavior
  2. Tool Retrieval: The _get_mcp_tools_from_string() method in agent/core.py only handles https:// URLs:

    if mcp_ref.startswith("https://"):
        return self._get_external_mcp_tools(mcp_ref)
    • http:// URLs are silently ignored, returning an empty tool list
    • No error is raised, making debugging difficult

Expected Behavior

  • Accept http:// URLs in MCP server references alongside https://
  • Successfully retrieve tools from local MCP servers using http:// URLs
  • Provide clear error messages that accurately reflect supported URL schemes
  • Support both http:// and https:// for external MCP server connections

Describe the solution you'd like

Proposed Solution

  1. Update Validator (base_agent.py):

    • Accept http://, https://, and crewai-amp: in validation
    • Update error message to reflect all supported schemes
  2. Update Tool Retrieval (agent/core.py):

    • Modify _get_mcp_tools_from_string() to handle both http:// and https://
    • Ensure _get_external_mcp_tools() works with both protocols
  3. Documentation:

    • Update docstrings to mention HTTP support
    • Add examples showing local MCP server usage

Example Usage

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

Impact

  • High: This is a blocker for local development workflows
  • Low Risk: HTTP support is a straightforward addition that doesn't break existing functionality
  • Developer Experience: Significantly improves the development experience for MCP integration

Technical Details

The changes required are minimal:

  • Update URL scheme checks from startswith("https://") to startswith(("http://", "https://"))
  • Ensure the underlying MCP client library supports HTTP (most do)
  • Update validation logic and error messages

Related Issues

  • Local MCP servers are a common development pattern
  • Many MCP server implementations default to HTTP for local development
  • SSL certificates are not always available in development environments

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions