Files
skill-seekers-reference/examples/http_transport_examples.sh
MiaoDX bd974148a2 feat: Update MCP to use server_fastmcp with venv Python support
This PR improves MCP server configuration by updating all documentation
to use the current server_fastmcp module and ensuring setup scripts
automatically use virtual environment Python instead of system Python.

## Changes

### 1. Documentation Updates (server → server_fastmcp)

Updated all references from deprecated `server` module to `server_fastmcp`:

**User-facing documentation:**
- examples/http_transport_examples.sh: All 13 command examples
- README.md: Configuration examples and troubleshooting commands
- docs/guides/MCP_SETUP.md: Enhanced migration guide with stdio/HTTP examples
- docs/guides/TESTING_GUIDE.md: Test import statements
- docs/guides/MULTI_AGENT_SETUP.md: Updated examples
- docs/guides/SETUP_QUICK_REFERENCE.md: Updated paths
- CLAUDE.md: CLI command examples

**MCP module:**
- src/skill_seekers/mcp/README.md: Updated config examples
- src/skill_seekers/mcp/agent_detector.py: Use server_fastmcp module

Note: Historical release notes (CHANGELOG.md) preserved unchanged.

### 2. Venv Python Configuration

**setup_mcp.sh improvements:**
- Added automatic venv detection (checks .venv, venv, and $VIRTUAL_ENV)
- Sets PYTHON_CMD to venv Python path when available
- **CRITICAL FIX**: Now updates PYTHON_CMD after creating/activating venv
- Generates MCP configs with full venv Python path
- Falls back to system python3 if no venv found
- Displays detected Python version and path

**Config examples updated:**
- .claude/mcp_config.example.json: Use venv Python path
- example-mcp-config.json: Use venv Python path
- Added "type": "stdio" for clarity
- Updated to use server_fastmcp module

### 3. Bug Fix: PYTHON_CMD Not Updated After Venv Creation

Previously, when setup_mcp.sh created or activated a venv, it failed to
update PYTHON_CMD, causing generated configs to still use system python3.

**Fixed cases:**
- When $VIRTUAL_ENV is already set → Update PYTHON_CMD to venv Python
- When existing venv is activated → Set PYTHON_CMD="$REPO_PATH/venv/bin/python3"
- When new venv is created → Set PYTHON_CMD="$REPO_PATH/venv/bin/python3"

## Benefits

### For Users:
 No deprecation warnings - All docs show current module
 Proper Python environment - MCP uses venv with all dependencies
 No system Python issues - Avoids "module not found" errors
 No global installation needed - No --break-system-packages required
 Automatic detection - setup_mcp.sh finds venv automatically
 Clean isolation - Projects don't interfere with system Python

### For Maintainers:
 Prepared for v3.0.0 - Documentation ready for server.py removal
 Reduced support burden - Fewer MCP configuration issues
 Consistent examples - All docs use same module/pattern

## Testing

**Verified:**
-  All command examples use server_fastmcp
-  No deprecated module references in user-facing docs (0 results)
-  New module correctly referenced (129 instances)
-  setup_mcp.sh detects venv and generates correct config
-  PYTHON_CMD properly updated after venv creation
-  MCP server starts correctly with venv Python

**Files changed:** 12 files (+262/-107 lines)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-18 15:55:46 +08:00

121 lines
3.9 KiB
Bash

#!/bin/bash
# HTTP Transport Examples for Skill Seeker MCP Server
#
# This script shows various ways to start the server with HTTP transport.
# DO NOT run this script directly - copy the commands you need.
# =============================================================================
# BASIC USAGE
# =============================================================================
# Default stdio transport (backward compatible)
python -m skill_seekers.mcp.server_fastmcp
# HTTP transport on default port 8000
python -m skill_seekers.mcp.server_fastmcp --transport http
# =============================================================================
# CUSTOM PORT
# =============================================================================
# HTTP transport on port 3000
python -m skill_seekers.mcp.server_fastmcp --transport http --port 3000
# HTTP transport on port 8080
python -m skill_seekers.mcp.server_fastmcp --transport http --port 8080
# =============================================================================
# CUSTOM HOST
# =============================================================================
# Listen on all interfaces (⚠️ use with caution in production!)
python -m skill_seekers.mcp.server_fastmcp --transport http --host 0.0.0.0
# Listen on specific interface
python -m skill_seekers.mcp.server_fastmcp --transport http --host 192.168.1.100
# =============================================================================
# LOGGING
# =============================================================================
# Debug logging
python -m skill_seekers.mcp.server_fastmcp --transport http --log-level DEBUG
# Warning level only
python -m skill_seekers.mcp.server_fastmcp --transport http --log-level WARNING
# Error level only
python -m skill_seekers.mcp.server_fastmcp --transport http --log-level ERROR
# =============================================================================
# COMBINED OPTIONS
# =============================================================================
# HTTP on port 8080 with debug logging
python -m skill_seekers.mcp.server_fastmcp --transport http --port 8080 --log-level DEBUG
# HTTP on all interfaces with custom port and warning level
python -m skill_seekers.mcp.server_fastmcp --transport http --host 0.0.0.0 --port 9000 --log-level WARNING
# =============================================================================
# TESTING
# =============================================================================
# Start server in background and test health endpoint
python -m skill_seekers.mcp.server_fastmcp --transport http --port 8765 &
SERVER_PID=$!
sleep 2
curl http://localhost:8765/health | python -m json.tool
kill $SERVER_PID
# =============================================================================
# CLAUDE DESKTOP CONFIGURATION
# =============================================================================
# For stdio transport (default):
# {
# "mcpServers": {
# "skill-seeker": {
# "command": "python",
# "args": ["-m", "skill_seekers.mcp.server_fastmcp"]
# }
# }
# }
# For HTTP transport on port 8000:
# {
# "mcpServers": {
# "skill-seeker": {
# "url": "http://localhost:8000/sse"
# }
# }
# }
# For HTTP transport on custom port 8080:
# {
# "mcpServers": {
# "skill-seeker": {
# "url": "http://localhost:8080/sse"
# }
# }
# }
# =============================================================================
# TROUBLESHOOTING
# =============================================================================
# Check if port is already in use
lsof -i :8000
# Find and kill process using port 8000
lsof -ti:8000 | xargs kill -9
# Test health endpoint
curl http://localhost:8000/health
# Test with verbose output
curl -v http://localhost:8000/health
# Follow server logs
python -m skill_seekers.mcp.server_fastmcp --transport http --log-level DEBUG 2>&1 | tee server.log