Skip to main content

A Model Context Protocol (MCP) server that integrates with ModelScope's ecosystem.

Project description

ModelScope MCP Server

PyPI - Version Docker GitHub Container Registry License

A Model Context Protocol (MCP) server that integrates with ModelScope's ecosystem, providing seamless access to AI models, datasets, apps, papers, and generation capabilities through popular MCP clients.

✨ Features

  • 🔐 User Authentication - Retrieve information about the currently authenticated ModelScope user
  • 🎨 AI Image Generation - Generate images from text prompts or transform existing images using AIGC models (supports both text-to-image and image-to-image generation)
  • 🔍 Resource Discovery - Search and discover ModelScope resources including machine learning models, research papers, and MCP servers with advanced filtering options
  • 📋 Resource Details (Coming Soon) - Get comprehensive details for specific resources including model specifications, paper abstracts, and MCP server configurations
  • 📖 Documentation Search (Coming Soon) - Semantic search for ModelScope documentation and articles
  • 🚀 Gradio API Integration (Coming Soon) - Invoke Gradio APIs exposed by any pre-configured ModelScope studio (AI app)

🚀 Quick Start

1. Get Your API Token

  1. Visit ModelScope and sign in to your account
  2. Navigate to [Home] → [Access Tokens] to retrieve or create your API token

📖 For detailed instructions, refer to the ModelScope Token Documentation

2. Integration with MCP Clients

Add the following JSON configuration to your MCP client's configuration file:

{
  "mcpServers": {
    "modelscope-mcp-server": {
      "command": "uvx",
      "args": ["modelscope-mcp-server"],
      "env": {
        "MODELSCOPE_API_TOKEN": "your-api-token"
      }
    }
  }
}

Or, you can use the pre-built Docker image:

{
  "mcpServers": {
    "modelscope-mcp-server": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "MODELSCOPE_API_TOKEN",
        "ghcr.io/modelscope/modelscope-mcp-server"
      ],
      "env": {
        "MODELSCOPE_API_TOKEN": "your-api-token"
      }
    }
  }
}

Refer to the MCP JSON Configuration Standard for more details.

This format is widely adopted across the MCP ecosystem:

  • Cherry Studio: See Cherry Studio MCP Configuration
  • Claude Desktop: Uses ~/.claude/claude_desktop_config.json
  • Cursor: Uses ~/.cursor/mcp.json
  • VS Code: Uses workspace .vscode/mcp.json
  • Other clients: Many MCP-compatible applications follow this standard

🛠️ Development

Environment Setup

  1. Clone and Setup:

    git clone https://github.com/modelscope/modelscope-mcp-server.git
    cd modelscope-mcp-server
    uv sync
    
  2. Activate Environment (or use your IDE):

    source .venv/bin/activate  # Linux/macOS
    
  3. Set Your API Token (see Quick Start section for token setup):

    export MODELSCOPE_API_TOKEN="your-api-token"
    # Or create .env file: echo 'MODELSCOPE_API_TOKEN="your-api-token"' > .env
    

Running the Demo Script

Run a quick demo to explore the server's capabilities:

uv run python demo.py

Use the --full flag for comprehensive feature demonstration:

uv run python demo.py --full

Running the Server Locally

# Standard stdio transport (default)
uv run modelscope-mcp-server

# Streamable HTTP transport for web integration
uv run modelscope-mcp-server --transport http

# HTTP/SSE transport with custom port (default: 8000)
uv run modelscope-mcp-server --transport [http/sse] --port 8080

For HTTP/SSE mode, connect using a local URL in your MCP client configuration:

{
  "mcpServers": {
    "modelscope-mcp-server": {
      "url": "http://127.0.0.1:8000/mcp/"
    }
  }
}

You can also debug the server using the MCP Inspector tool:

npx @modelcontextprotocol/inspector uv run modelscope-mcp-server

Uses stdio transport by default; switch to HTTP/SSE in the Web UI as needed.

Testing

# Run all tests
uv run pytest

# Run specific test file
uv run pytest tests/test_search_papers.py

# With coverage report
uv run pytest --cov=src --cov-report=html

🔄 Continuous Integration

This project uses GitHub Actions for automated CI/CD workflows that run on every push and pull request:

Automated Checks

  • Lint - Code formatting, linting, and style checks using pre-commit hooks
  • 🧪 Test - Comprehensive testing across all supported Python versions
  • 🔍 CodeQL - Security vulnerability scanning and code quality analysis
  • 🔒 Gitleaks - Detecting secrets like passwords, API keys, and tokens

Local Development Checks

Run the same checks locally before submitting PRs:

# Install and run pre-commit hooks
uv run pre-commit install
uv run pre-commit run --all-files

# Run tests
uv run pytest

Monitor CI status in the Actions tab.

📦 Release Management

This project uses GitHub Actions for automated release management. To create a new release:

  1. Update version using the bump script:

    uv run python scripts/bump_version.py [patch|minor|major]
    # Or set specific version: uv run python scripts/bump_version.py set 1.2.3.dev1
    
  2. Commit and tag (follow the script's output instructions):

    git add src/modelscope_mcp_server/_version.py
    git commit -m "chore: bump version to v{version}"
    git tag v{version} && git push origin v{version}
    
  3. Automated publishing - GitHub Actions will automatically:

🤝 Contributing

We welcome contributions! Please ensure your PRs:

  • Include relevant tests and pass all CI checks
  • Update documentation for new features
  • Follow conventional commit format

📚 References

📜 License

This project is licensed under the Apache License (Version 2.0).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelscope_mcp_server-0.1.4.tar.gz (92.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelscope_mcp_server-0.1.4-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file modelscope_mcp_server-0.1.4.tar.gz.

File metadata

File hashes

Hashes for modelscope_mcp_server-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1c76dcef7ac5f34c92e50ce6fe31dacf38b85330da0a02e1075f845963c84805
MD5 f8d95eb3b63284802c4407298af21179
BLAKE2b-256 0d2d285e127de1487a0bcb29ede47613ce2c8e434e06f12cf92da7932b48af6f

See more details on using hashes here.

File details

Details for the file modelscope_mcp_server-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for modelscope_mcp_server-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 166a99b5d08c986b68cb1771f8271d4e95334f3b67b3da236051d32235789427
MD5 9b9c49a2e9b32d942c78bc5681b4bede
BLAKE2b-256 5b601ed057ba33bbc551531acff26a1ac31430a7d7e2393a4cb244086971fe77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page