Skip to content

refactor: migrate all servers to mamba-mcp-core#4

Merged
sequenzia merged 5 commits intomainfrom
phase3/migrate-servers-to-core
Feb 2, 2026
Merged

refactor: migrate all servers to mamba-mcp-core#4
sequenzia merged 5 commits intomainfrom
phase3/migrate-servers-to-core

Conversation

@sequenzia
Copy link
Owner

Summary

Changes per server

mamba-mcp-pg:

  • __main__.py: Core imports for validate_env_file, resolve_default_env_file, setup_logging, normalize_transport
  • config.py: Core imports for get_env_file_path, set_env_file_path; transport pattern updated
  • errors.py: Core imports for create_tool_error, find_similar_names; dict return type preserved

mamba-mcp-fs:

  • __main__.py: Core imports for CLI + transport utilities
  • config.py: Core imports for config state; transport pattern updated
  • errors.py: Intentionally unchanged (keeps custom exception hierarchy for backend flow control)

mamba-mcp-hana:

  • __main__.py: Core imports for CLI + transport; removed ~75 lines of local function definitions
  • config.py: Core imports for config state; removed redundant resolve_env_file(); transport pattern updated
  • errors.py: Core imports for ToolError, create_tool_error, find_similar_names; suggest_similar wrapper preserves keyword compat

Test plan

  • PG tests pass (66 passed)
  • HANA tests pass (778 passed)
  • Core tests pass (51 passed)
  • Ruff lint clean
  • FS tests (309 pre-existing failures on main, unrelated to this change)

Add SAP HANA MCP server to README.md and CLAUDE.md with complete package
description, architecture details, and repository structure updates. Also
document mamba-mcp-fs utility modules (content.py, errors.py).
- Created internal/docs/codebase-analysis.md with comprehensive analysis of all 4 packages, including architecture overview, critical files, patterns, challenges, and recommendations
- Updated CLAUDE.md with Key Patterns to Follow (7 core patterns for server packages), Testing Conventions, and Known Inconsistencies to guide future development
- Updated README.md with Architecture section explaining the shared FastMCP + layered tool pattern and tech stack
…mba_mcp_hana

Resolve module name asymmetry where mamba-mcp-hana was the only package
that didn't follow the 1:1 naming convention (it used mamba_mcp_sap_hana
with an extra sap_ prefix). All other packages map directly:
mamba-mcp-pg → mamba_mcp_pg, mamba-mcp-fs → mamba_mcp_fs.

Changes:
- Rename src/mamba_mcp_sap_hana/ → src/mamba_mcp_hana/
- Update pyproject.toml entry point and build config
- Update all imports across source and test files
- Update CLAUDE.md, README.md, and codebase-analysis.md

BREAKING CHANGE: Module import path changed from mamba_mcp_sap_hana to mamba_mcp_hana
Create mamba-mcp-core to extract duplicated code from server packages:
- cli.py: validate_env_file, resolve_default_env_file, setup_logging
- config.py: module-level env file path state management
- errors.py: flat ToolError model + create_tool_error factory with
  server-specific suggestions_map parameter
- fuzzy.py: Levenshtein distance + find_similar_names with scaled
  threshold (max(2, min(len//2, 5))) — standardizes PG vs HANA approach
- transport.py: normalize_transport accepting both "http" and
  "streamable-http"

Includes 51 tests covering all modules. Addresses Challenges #3
(code duplication) and #6 (fuzzy matching inconsistency).
Replace duplicated code across all three server packages with shared
imports from mamba-mcp-core. This eliminates ~500 lines of copy-pasted
CLI utilities, config state management, error models, and fuzzy matching.

Changes per server:
- PG: core imports for CLI, config, errors, fuzzy; dict return preserved
- FS: core imports for CLI, config, transport; exception hierarchy kept
- HANA: core imports for CLI, config, errors, fuzzy, transport;
  removed redundant resolve_env_file(); ToolError return preserved;
  suggest_similar wrapper maps max_suggestions→max_results

Transport pattern updated to accept both "http" and "streamable-http"
in all servers, with normalize_transport() applied before mcp.run().

Test updates:
- HANA: removed TestLevenshteinDistance (now in core), removed
  TestResolveEnvFile (now in core), removed _levenshtein_distance import
- All existing tests pass (PG: 66, HANA: 778, Core: 51)
Copilot AI review requested due to automatic review settings February 2, 2026 00:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully migrates PostgreSQL, Filesystem, and SAP HANA MCP servers to use a new shared mamba-mcp-core package, eliminating approximately 500 lines of duplicated code across CLI utilities, configuration management, error handling, and fuzzy matching logic.

Changes:

  • Created mamba-mcp-core package with 5 modules (cli, config, errors, fuzzy, transport) and 51 passing tests
  • Migrated PG, FS, and HANA servers to import shared utilities from core
  • Standardized transport naming (accepts both "http" and "streamable-http", normalizes to "streamable-http")
  • Updated 778 HANA test import paths from mamba_mcp_sap_hana to mamba_mcp_hana

Reviewed changes

Copilot reviewed 61 out of 68 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/mamba-mcp-core/* New shared utility package with CLI helpers, config state, error models, fuzzy matching, and transport normalization
packages/mamba-mcp-pg/src/mamba_mcp_pg/main.py Removed ~80 lines of duplicated CLI functions, now imports from core
packages/mamba-mcp-pg/src/mamba_mcp_pg/config.py Removed config state management, imports from core
packages/mamba-mcp-pg/src/mamba_mcp_pg/errors.py Removed Levenshtein implementation, wraps core functions preserving dict return type
packages/mamba-mcp-fs/src/mamba_mcp_fs/main.py Removed ~80 lines of duplicated CLI functions, added transport normalization
packages/mamba-mcp-fs/src/mamba_mcp_fs/config.py Removed config state management, updated transport pattern
packages/mamba-mcp-hana/src/mamba_mcp_hana/main.py New file replacing old path, removed ~75 lines of duplicated functions
packages/mamba-mcp-hana/src/mamba_mcp_hana/config.py Removed config state and resolve_env_file function, updated transport pattern
packages/mamba-mcp-hana/src/mamba_mcp_hana/errors.py Removed Levenshtein implementation, added suggest_similar wrapper for backward compatibility
packages/mamba-mcp-hana/tests/* Updated 778 test file imports from old package name to new name
uv.lock, pyproject.toml Added mamba-mcp-core to workspace and server dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sequenzia sequenzia merged commit 7af01ad into main Feb 2, 2026
6 checks passed
@sequenzia sequenzia deleted the phase3/migrate-servers-to-core branch February 2, 2026 01:46
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.

2 participants