Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add comprehensive tests for MCP imports to address issue #3858

Summary

This PR adds comprehensive test coverage for the MCP import functionality that was added in version 1.4.0 to resolve issue #3858. The issue reported that users on version 1.3.0 could not import MCPServerStdio, MCPServerHTTP, and MCPServerSSE from crewai.mcp as shown in the documentation.

The fix was already implemented in commit 6f36d70 (feat: first-class MCP support), but lacked specific tests that replicate the exact failing code from the issue. This PR adds 10 new tests that:

  1. Verify the MCP classes can be imported from crewai.mcp without errors
  2. Test instantiation of all three MCP server configuration classes
  3. Confirm that Agent accepts the mcps parameter with these configurations
  4. Replicate the exact documentation example that was failing in issue [BUG] ModuleNotFoundError: No module named 'crewai.mcp' #3858
  5. Validate Pydantic model behavior (required fields, optional fields, validation errors)

All 10 new tests pass ✅, and all 5 existing MCP tests continue to pass ✅.

Review & Testing Checklist for Human

Test Plan

# Run the new MCP import tests
uv run pytest lib/crewai/tests/mcp/test_mcp_imports.py -vv

# Run all MCP tests to ensure no regressions
uv run pytest lib/crewai/tests/mcp/ -vv

Notes

Fixes #3858

This commit adds comprehensive tests that verify the fix for issue #3858,
where users reported ModuleNotFoundError when trying to import MCP classes
from crewai.mcp.

The issue was resolved in version 1.4.0 with the addition of first-class
MCP support (commit 6f36d70). These tests ensure:

1. MCPServerStdio, MCPServerHTTP, and MCPServerSSE can be imported from crewai.mcp
2. Agent accepts mcps parameter with these configuration classes
3. The exact documentation example from issue #3858 works correctly
4. All MCP server configs are proper Pydantic models with validation
5. Optional fields work as expected

All 10 new tests pass, and existing MCP tests continue to pass.

Fixes #3858

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
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

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.

[BUG] ModuleNotFoundError: No module named 'crewai.mcp'

1 participant