Skip to main content

CLI tools for MCP (Model Context Protocol) server setup and management

Project description

MCP Base

CLI tools for MCP (Model Context Protocol) server setup and management. These tools help you configure OIDC authentication, create Kubernetes secrets, set up RBAC, and manage MCP server deployments.

Installation

From PyPI

# Install base package (OIDC tools only)
pip install mcp-base

# Install with Kubernetes support
pip install mcp-base[kubernetes]

# Install all optional dependencies
pip install mcp-base[all]

From Source

git clone https://github.com/your-org/mcp-base.git
cd mcp-base
pip install -e ".[all]"

Usage

After installation, the mcp-base command is available with the following subcommands:

mcp-base <command> [options]
Command Description
setup-oidc Set up OIDC provider (Auth0, etc.) for MCP authentication
create-secrets Create Kubernetes secrets for MCP deployment
make-config Generate configuration files
setup-rbac Set up Kubernetes RBAC resources
add-user Add users to allowed clients

Setting Up OIDC (Auth0)

Configure your OIDC provider for MCP authentication:

# Set up Auth0 (first run)
mcp-base setup-oidc --provider auth0 \
    --domain your-tenant.auth0.com \
    --api-identifier https://mcp-server.example.com/mcp \
    --token YOUR_MGMT_TOKEN

# Subsequent runs (uses saved configuration)
mcp-base setup-oidc --provider auth0

# Force recreate clients (if secrets are lost)
mcp-base setup-oidc --provider auth0 --recreate-client

Creating Kubernetes Secrets

Create secrets required for MCP server deployment:

# Create secrets in a namespace
mcp-base create-secrets --namespace default --release-name my-mcp-server

# Dry run to see what would be created
mcp-base create-secrets --namespace default --release-name my-mcp-server --dry-run

# Replace existing secrets
mcp-base create-secrets --namespace default --release-name my-mcp-server --force

Generating Configuration Files

Generate configuration files for deployment:

# Interactive mode
mcp-base make-config --server-name "My MCP Server"

# Non-interactive with environment variables
mcp-base make-config --server-name "My Server" --from-env

# Specify values directly
mcp-base make-config --server-name "My Server" \
    --domain your-tenant.auth0.com \
    --client-id xxx \
    --client-secret yyy

Setting Up RBAC

Configure Kubernetes RBAC for MCP server:

# Cluster-wide permissions
mcp-base setup-rbac --namespace production --app-name my-mcp-server

# Namespace-scoped permissions
mcp-base setup-rbac --namespace production --app-name my-mcp-server --scope namespace

# Dry run
mcp-base setup-rbac --app-name my-mcp-server --dry-run

# Delete RBAC resources
mcp-base setup-rbac --app-name my-mcp-server --delete

Adding Users to Allowed Clients

Add users to the allowedClients array in your OIDC provider:

# Interactive mode
mcp-base add-user

# Non-interactive
mcp-base add-user --email user@example.com --client-type both

Dependencies

Required

  • requests>=2.28.0 - HTTP client for Auth0 API

Optional (Kubernetes support)

  • kubernetes>=28.0.0 - Kubernetes Python client
  • cryptography>=41.0.0 - For generating encryption keys

Install with: pip install mcp-base[kubernetes]

Development

Setup

# Clone the repository
git clone https://github.com/your-org/mcp-base.git
cd mcp-base

# Install in development mode with all dependencies
pip install -e ".[dev]"

Running Tests

pytest

Code Quality

# Format code
black src/

# Lint
ruff check src/

# Type checking
mypy src/

Publishing to PyPI

Prerequisites

  1. Create an account on PyPI and Test PyPI
  2. Install build tools:
    pip install build twine
    

Build the Package

# Clean previous builds
rm -rf dist/ build/ *.egg-info src/*.egg-info

# Build source distribution and wheel
python -m build

This creates:

  • dist/mcp_base-0.1.0.tar.gz (source distribution)
  • dist/mcp_base-0.1.0-py3-none-any.whl (wheel)

Test on Test PyPI (Recommended)

# Upload to Test PyPI
python -m twine upload --repository testpypi dist/*

# Or with a token file
python -m twine upload --repository testpypi dist/* -u __token__ -p "$(cat ~/.testpypi-token)"

# Test installation from Test PyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mcp-base

Publish to PyPI

# Upload to PyPI
python -m twine upload dist/*

Using API Tokens (Recommended)

Instead of username/password, use API tokens:

  1. Go to PyPI > Account Settings > API tokens
  2. Create a token with scope "Entire account" or project-specific
  3. Use the token directly:
    python -m twine upload dist/* -u __token__ -p pypi-YOUR_TOKEN_HERE
    

Using a Token File

For better security, store your token in a file and read it during upload:

# Store token in a file (do this once)
echo "pypi-YOUR_TOKEN_HERE" > ~/.pypi-token
chmod 600 ~/.pypi-token

# Upload using the token file
python -m twine upload dist/* -u __token__ -p "$(cat ~/.pypi-token)"

# Or using environment variables
TWINE_PASSWORD=$(cat ~/.pypi-token) python -m twine upload dist/*

Using .pypirc Configuration File

Or create ~/.pypirc:

[pypi]
username = __token__
password = pypi-YOUR_TOKEN_HERE

[testpypi]
username = __token__
password = pypi-YOUR_TEST_TOKEN_HERE

Automated Publishing with GitHub Actions

Create .github/workflows/publish.yml:

name: Publish to PyPI

on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install build dependencies
        run: pip install build twine

      - name: Build package
        run: python -m build

      - name: Publish to PyPI
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: python -m twine upload dist/*

Add your PyPI API token as a repository secret named PYPI_API_TOKEN.

License

MIT License - see LICENSE file for details.

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

mcp_base-0.1.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

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

mcp_base-0.1.0-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_base-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_base-0.1.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for mcp_base-0.1.0.tar.gz
Algorithm Hash digest
SHA256 729e684562ae7610dab52baffa360348a788211fb70c8952ea8be8023c441941
MD5 8b999a9ec9dcba3bffbac3d5c8423bde
BLAKE2b-256 e986c7b2d29f5a34c419ff2f1d245c64a8da4041a96d55c98061468aa13c30ce

See more details on using hashes here.

File details

Details for the file mcp_base-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_base-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for mcp_base-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2f532bb48a426c09a2eda9a92bcd7ab3ae9489d28713fdbf830bb0a571b9ce7
MD5 6302aef0c1a7f3d701432e875e42c5e0
BLAKE2b-256 57fb82bad1b9b636a6817757625d55702d466b8e4f1074819f9a1b8f58e9d46a

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