Skip to content

Fix: Correct MCPServerConfig import to resolve Docker container crash#20

Merged
RichardAtCT merged 3 commits intomainfrom
fix/issue-19-mcp-import-error
Nov 13, 2025
Merged

Fix: Correct MCPServerConfig import to resolve Docker container crash#20
RichardAtCT merged 3 commits intomainfrom
fix/issue-19-mcp-import-error

Conversation

@RichardAtCT
Copy link
Owner

Summary

Problem

The application was attempting to import MCPServerConfig from src.models, but it's actually defined in src.mcp_client.py as a dataclass (lines 28-37). This caused the Docker container to crash on startup with:

ImportError: cannot import name 'MCPServerConfig' from 'src.models'

Solution

Updated src/main.py to:

  • Remove MCPServerConfig from the src.models import statement (line 35)
  • Add MCPServerConfig to the src.mcp_client import (line 42)

Changes

  • Modified src/main.py imports only
  • No logic changes required
  • Python syntax validation passed

Test plan

  • Build and run Docker container to verify it starts without ImportError
  • Verify MCP server registration endpoint works correctly
  • Confirm no other import-related issues

Fixes #19

The application was attempting to import MCPServerConfig from src.models,
but it's actually defined in src.mcp_client as a dataclass. Updated the
import statement to import from the correct module.

Changes:
- Remove MCPServerConfig from src.models import
- Add MCPServerConfig to src.mcp_client import
@claude
Copy link
Contributor

claude bot commented Nov 13, 2025

Claude finished @RichardAtCT's task —— View job


PR Review: Fix MCPServerConfig Import Error ✅

Import fix successfully resolves Docker container crash

Todo List:

  • Read repository setup instructions (CLAUDE.md - file not found)
  • Examine the changed file (src/main.py)
  • Verify MCPServerConfig location in src/mcp_client.py
  • Analyze import changes for correctness
  • Check for code quality and best practices
  • Look for potential bugs or issues
  • Review security implications
  • Assess test coverage needs
  • Provide comprehensive review feedback

Review Summary: APPROVED

This PR correctly fixes the ImportError that was causing Docker container crashes. The changes are minimal, focused, and address the root cause without introducing any side effects.

📋 Code Quality Assessment

✅ Import Fix is Correct

  • Problem: MCPServerConfig was incorrectly imported from src.models (line 35) where it doesn't exist
  • Solution: Correctly imports MCPServerConfig from src.mcp_client (line 42) where it's actually defined as a @dataclass (lines 28-37)
  • Verification: Confirmed MCPServerConfig class exists in src/mcp_client.py:28-37 and is used throughout the MCP functionality

✅ Changes Are Minimal and Safe

  • Only 2 lines modified: removed incorrect import, added correct import
  • No logic changes required - this was purely an import location issue
  • Changes are backwards compatible

✅ No Additional Issues Found

  • All other imports in src/main.py are correct and consistent
  • No other files incorrectly reference MCPServerConfig from src.models
  • The distinction between MCPServerConfig (dataclass) and MCPServerConfigRequest (Pydantic model) is appropriate

🔒 Security Review

  • No security concerns: Import changes don't affect functionality or expose vulnerabilities
  • Principle of least privilege: Import change properly scopes dependencies

Performance Considerations

  • Positive impact: Fixes startup crash, enabling container to run
  • No performance degradation: Import location change has no runtime impact

🧪 Test Coverage

  • Recommendation: Add integration test to verify Docker container starts successfully
  • Current status: Import syntax validation would have caught this in a CI pipeline
  • Suggestion: Consider adding import validation in CI to prevent similar issues

📝 Additional Recommendations

  1. CI Enhancement: Consider adding python -m py_compile src/main.py to catch import errors early
  2. Documentation: The fix aligns with the MCP architecture where configuration classes are co-located with their client implementations

🎯 Conclusion

This is an excellent, focused fix that:

  • ✅ Correctly resolves the immediate Docker container crash
  • ✅ Uses proper Python import practices
  • ✅ Requires no additional changes
  • ✅ Has no side effects or breaking changes

Recommendation: APPROVE and MERGE - This fix is ready for production deployment.


Also fixes import issue that would cause container to crash after the
MCPServerConfig fix. The import was missing the src. prefix.
@claude
Copy link
Contributor

claude bot commented Nov 13, 2025

Claude finished @RichardAtCT's task —— View job


Claude Code is analyzing the PR...

PR Review: Import Fix Analysis

Todo List:

  • Read repository setup instructions (CLAUDE.md - file not found)
  • Examine changed files (src/main.py and src/tool_manager.py)
  • Verify import corrections are appropriate
  • Analyze code quality and best practices
  • Check for potential bugs or issues
  • Review performance considerations
  • Assess security implications
  • Evaluate test coverage needs
  • Provide comprehensive review feedback

PR Review Complete: Import Fixes Approved

This PR contains two critical import fixes that resolve Docker container startup crashes. Both changes are minimal, correct, and necessary.

📋 Summary of Changes

File 1: src/main.py (4d10b70)

  • Problem: MCPServerConfig incorrectly imported from src.models (line 35) where it doesn't exist
  • Solution: Correctly imports from src.mcp_client (line 42) where it's defined as a @dataclass (lines 28-37)
  • Impact: Fixes ImportError that crashes Docker container on startup

File 2: src/tool_manager.py (1c58107)

  • Problem: Missing src. prefix in constants import causes ModuleNotFoundError
  • Solution: Corrects import statement to include proper module path
  • Impact: Prevents secondary import error after MCP fix

Code Quality Assessment

Import Fixes Are Correct

  • MCPServerConfig exists in src/mcp_client.py:28-37 as documented
  • MCPServerConfigRequest correctly remains in src/models.py:305 (Pydantic model)
  • ✅ Tool manager constants import now has proper src. prefix
  • ✅ All other imports in both files are correct and consistent

Changes Are Minimal and Safe

  • ✅ Only import statements modified - no logic changes required
  • ✅ Changes are backwards compatible
  • ✅ No side effects introduced

🔒 Security Review: APPROVED

  • ✅ No security concerns - import location changes don't affect functionality
  • ✅ No exposure of sensitive data or vulnerabilities
  • ✅ Proper module scoping maintained

Performance Review: POSITIVE

  • ✅ Fixes critical startup crash - enables application to run
  • ✅ No performance degradation from import changes
  • ✅ Correct imports prevent unnecessary module loading errors

🐛 Bug Analysis: FIXED

  • Primary Issue: Docker container ImportError on startup - RESOLVED
  • Secondary Issue: Constants import ModuleNotFoundError - RESOLVED
  • ✅ No additional import-related issues detected

🧪 Test Coverage Recommendations

  1. Integration Tests: Add container startup validation
  2. CI Enhancement: Consider adding python -c "import src.main" to catch import errors early
  3. Import Validation: Pre-commit hooks for import syntax checking

📝 Additional Observations

Architecture Appropriateness

  • MCPServerConfig (dataclass) co-located with MCP client implementation
  • MCPServerConfigRequest (Pydantic) appropriately in models for API validation
  • ✅ Clear separation of concerns between configuration and request models

Code Standards

  • ✅ Follows Python import best practices
  • ✅ Consistent with existing codebase patterns
  • ✅ Proper module organization

🎯 Final Recommendation: ✅ APPROVE AND MERGE

This PR successfully resolves critical startup issues with:

  • ✅ Correct import fixes for both identified problems
  • ✅ No breaking changes or side effects
  • ✅ Minimal, focused changes that address root causes
  • ✅ Production-ready implementation

Ready for immediate deployment - these fixes are essential for container stability.


View job

Fixes incorrect parameter usage in rate_limit_endpoint decorators.
The decorator expects an endpoint category string (e.g., "general",
"chat") but was being called with numeric limit= parameters.

Changes:
- Replace @rate_limit_endpoint(limit=X) with @rate_limit_endpoint("general")
- Affects 9 endpoints: /v1/tools/* and /v1/mcp/* endpoints
- Also includes the tool_manager.py constants import fix

All import and decorator issues are now resolved. Docker container
starts successfully and all endpoints are properly configured.
@claude
Copy link
Contributor

claude bot commented Nov 13, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@RichardAtCT RichardAtCT merged commit d9f28df into main Nov 13, 2025
1 check failed
@RichardAtCT RichardAtCT deleted the fix/issue-19-mcp-import-error branch November 13, 2025 09:40
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.

Docker container crashes immediately

1 participant

Comments