Skip to main content

ModelScope MCP Server

Project description

ModelScope MCP Server

PyPI - Version Docker 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 descriptions using any AIGC model available on ModelScope
  • 📚 Research Paper Search - Search for arXiv papers indexed in ModelScope with comprehensive metadata
  • 🔍 Resource Discovery (Coming Soon) - Search for models, datasets, studios and other resources on ModelScope
  • 📖 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

🚀 Quick Start

1. Get Your API Token

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

📖 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"
      }
    }
  }
}

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

🐳 Docker Usage

Quick Start with Docker

# Build the image for your platform
docker build -t modelscope-mcp-server .

# Run with environment variable
docker run -e MODELSCOPE_API_TOKEN="your-api-token" \
  modelscope-mcp-server

# Or create a .env file and mount it
echo "MODELSCOPE_API_TOKEN=your-api-token" > .env
docker run --env-file .env \
  modelscope-mcp-server

# Run with different transports
docker run -p 8080:8080 -e MODELSCOPE_API_TOKEN="your-api-token" modelscope-mcp-server --transport http --port 8080

Multi-platform Support: For ARM64 platforms (Apple Silicon, etc.), specify the platform explicitly:

docker build --platform linux/arm64 -t modelscope-mcp-server .
docker run --platform linux/arm64 -e MODELSCOPE_API_TOKEN="your-api-token" modelscope-mcp-server

Using with MCP Clients

For Docker-based deployment, you can modify the MCP client configuration:

{
  "mcpServers": {
    "modelscope-mcp-server": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "MODELSCOPE_API_TOKEN=your-api-token",
        "modelscope-mcp-server"
      ]
    }
  }
}

🛠️ Development

Environment Setup

  1. Clone and Setup:

    git clone https://github.com/pengqun/modelscope-mcp-server.git
    cd modelscope-mcp-server
    uv sync
    
  2. Activate Environment:

    source .venv/bin/activate  # Linux/macOS
    # or via your IDE
    
  3. Set Your API Token Environment Variable:

    export MODELSCOPE_API_TOKEN="your-api-token"
    

    Or, you can set the API token in the .env file (under the project root) for convenience:

    MODELSCOPE_API_TOKEN="your-api-token"
    

Running the Server

# 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

Running the Demo (Optional)

uv run python demo.py

Testing

Run the complete test suite:

# Basic test run
uv run pytest

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

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

Code Quality

This project uses pre-commit hooks for automated code formatting, linting, and type checking:

# Install hooks
uv run pre-commit install

# Run all checks manually
uv run pre-commit run --all-files

All PRs must pass these checks and include appropriate tests.

📦 Release Management

Version Bumping

# Patch version (1.0.0 → 1.0.1)
python scripts/bump_version.py patch

# Minor version (1.0.0 → 1.1.0)
python scripts/bump_version.py minor

# Major version (1.0.0 → 2.0.0)
python scripts/bump_version.py major

# Pre-release versions
python scripts/bump_version.py patch --pre dev    # 1.0.1.dev1
python scripts/bump_version.py patch --pre alpha  # 1.0.1a1
python scripts/bump_version.py patch --pre beta   # 1.0.1b1
python scripts/bump_version.py patch --pre rc     # 1.0.1rc1

Publishing to PyPI

TODO: trigger release from GitHub Actions

# Preview release (dry-run)
python scripts/release.py --dry-run

# Publish release
python scripts/release.py

🤝 Contributing

We welcome contributions! Please ensure that:

  1. All PRs include relevant tests and pass the full test suite
  2. Code follows our style guidelines (enforced by pre-commit hooks)
  3. Documentation is updated for new features
  4. Commit messages follow conventional commit format

📚 References


License: MIT | Author: pengqun

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.2.tar.gz (65.5 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.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for modelscope_mcp_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 598adf42fb9a9e956ceec01ad1a30b89cac2e0ea8b2e0e4bc9c1df68a399858e
MD5 69d1c1365a1c9a18dea1438d519fe0bb
BLAKE2b-256 0810296b8761e040fcc3e6915dca0fe5e232085cd8392eee8b423f469dbe867c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for modelscope_mcp_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd705cd4b28a453c64801541d00a30896105465991d96bc81cb42628a21577ff
MD5 cb60af265666ac1ce3b977abb5572f2f
BLAKE2b-256 31449eb9602cf4efd8d2554561add1720bcd95e54382340dfc3d21b84a49af4a

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