name: Tests env: PY_COLORS: 1 on: push: branches: ["main"] paths: - "fastmcp_slim/**" - "fastmcp_remote/**" - "tests/**" - "pyproject.toml" - "uv.lock" - ".github/workflows/**" # run on all pull requests because these checks are required and will block merges otherwise pull_request: workflow_dispatch: permissions: contents: read jobs: run_tests: name: "Tests: Python ${{ matrix.python-version }} on ${{ matrix.os }}" runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] python-version: ["3.10"] include: - os: ubuntu-latest python-version: "3.13" fail-fast: false timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Setup uv uses: ./.github/actions/setup-uv with: python-version: ${{ matrix.python-version }} resolution: locked - name: Run unit tests uses: ./.github/actions/run-pytest - name: Run client process tests uses: ./.github/actions/run-pytest with: test-type: client_process run_tests_lowest_direct: name: "Tests with lowest-direct dependencies" runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Setup uv (lowest-direct) uses: ./.github/actions/setup-uv with: resolution: lowest-direct - name: Run unit tests uses: ./.github/actions/run-pytest - name: Run client process tests uses: ./.github/actions/run-pytest with: test-type: client_process run_conformance_tests: name: "MCP conformance tests" runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Setup uv uses: ./.github/actions/setup-uv with: resolution: locked - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: "22" - name: Run conformance tests uses: ./.github/actions/run-pytest with: test-type: conformance run_integration_tests: name: "Integration tests" runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Setup uv uses: ./.github/actions/setup-uv with: resolution: locked - name: Run integration tests uses: ./.github/actions/run-pytest with: test-type: integration env: FASTMCP_GITHUB_TOKEN: ${{ secrets.FASTMCP_GITHUB_TOKEN }} FASTMCP_TEST_AUTH_GITHUB_CLIENT_ID: ${{ secrets.FASTMCP_TEST_AUTH_GITHUB_CLIENT_ID }} FASTMCP_TEST_AUTH_GITHUB_CLIENT_SECRET: ${{ secrets.FASTMCP_TEST_AUTH_GITHUB_CLIENT_SECRET }} package_install_smoke: name: "Package install smoke" runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Setup uv uses: ./.github/actions/setup-uv with: resolution: locked - name: Build package wheels run: uv build --all-packages --wheel --out-dir /tmp/fastmcp-dist - name: Install bare slim wheel run: | uv venv /tmp/fastmcp-slim-bare-smoke SLIM_WHEEL=$(ls /tmp/fastmcp-dist/fastmcp_slim-*.whl) uv pip install --python /tmp/fastmcp-slim-bare-smoke/bin/python "$SLIM_WHEEL" /tmp/fastmcp-slim-bare-smoke/bin/python - <<'PY' from importlib.metadata import entry_points import fastmcp import fastmcp.settings assert any(ep.name == "fastmcp" for ep in entry_points(group="console_scripts")) try: from fastmcp.cli import app except ImportError as exc: assert "FastMCP CLI support is not installed" in str(exc) else: raise AssertionError(f"bare fastmcp-slim unexpectedly imported CLI app {app!r}") try: fastmcp.FastMCP except ImportError as exc: assert "fastmcp-slim[server]" in str(exc) else: raise AssertionError("bare fastmcp-slim unexpectedly imported FastMCP") PY - name: Install client slim wheel run: | uv venv /tmp/fastmcp-slim-client-smoke SLIM_WHEEL=$(ls /tmp/fastmcp-dist/fastmcp_slim-*.whl) uv pip install --python /tmp/fastmcp-slim-client-smoke/bin/python "${SLIM_WHEEL}[client]" /tmp/fastmcp-slim-client-smoke/bin/python - <<'PY' from importlib.metadata import entry_points from fastmcp import Client from fastmcp.client.transports import StdioTransport, StreamableHttpTransport from fastmcp.mcp_config import MCPConfig assert any(ep.name == "fastmcp" for ep in entry_points(group="console_scripts")) try: from fastmcp.cli import app except ImportError as exc: assert "FastMCP CLI support is not installed" in str(exc) else: raise AssertionError(f"client-only slim unexpectedly imported CLI app {app!r}") assert Client("https://example.com/mcp") assert StreamableHttpTransport("https://example.com/mcp") assert StdioTransport(command="uvx", args=["demo"]) assert MCPConfig.from_dict({"mcpServers": {"demo": {"url": "https://example.com/mcp"}}}) try: from fastmcp import FastMCP except ImportError as exc: assert "fastmcp-slim[server]" in str(exc) else: raise AssertionError(f"client-only slim unexpectedly imported {FastMCP!r}") PY - name: Install server slim wheel run: | uv venv /tmp/fastmcp-slim-server-smoke SLIM_WHEEL=$(ls /tmp/fastmcp-dist/fastmcp_slim-*.whl) uv pip install --python /tmp/fastmcp-slim-server-smoke/bin/python "${SLIM_WHEEL}[server]" /tmp/fastmcp-slim-server-smoke/bin/python - <<'PY' from importlib.metadata import entry_points from fastmcp import FastMCP from fastmcp.cli import app assert any( ep.name == "fastmcp" and ep.value == "fastmcp.cli:app" for ep in entry_points(group="console_scripts") ) mcp = FastMCP("smoke") assert app is not None assert mcp.name == "smoke" PY - name: Install full package from matching local wheels run: | uv venv /tmp/fastmcp-full-smoke FULL_WHEEL=$(ls /tmp/fastmcp-dist/fastmcp-*.whl) uv pip install --python /tmp/fastmcp-full-smoke/bin/python --prerelease=allow --find-links /tmp/fastmcp-dist "$FULL_WHEEL" /tmp/fastmcp-full-smoke/bin/python - <<'PY' from importlib.metadata import entry_points from importlib.metadata import requires from fastmcp import Client, FastMCP from fastmcp.client.client import CallToolResult from fastmcp.exceptions import ToolError fastmcp_reqs = requires("fastmcp") or [] assert any("fastmcp-slim[client,server]" in req for req in fastmcp_reqs) assert not any("fastmcp-slim[full" in req for req in fastmcp_reqs) assert any( ep.name == "fastmcp" and ep.value == "fastmcp.cli:app" for ep in entry_points(group="console_scripts") ) assert Client("https://example.com/mcp") assert FastMCP("smoke").name == "smoke" assert CallToolResult is not None assert ToolError is not None PY - name: Install fastmcp-remote from matching local wheels run: | uv venv /tmp/fastmcp-remote-smoke REMOTE_WHEEL=$(ls /tmp/fastmcp-dist/fastmcp_remote-*.whl) uv pip install --python /tmp/fastmcp-remote-smoke/bin/python --prerelease=allow --find-links /tmp/fastmcp-dist "$REMOTE_WHEEL" /tmp/fastmcp-remote-smoke/bin/python - <<'PY' from importlib.metadata import entry_points from importlib.metadata import requires from fastmcp_remote.cli import build_parser remote_reqs = requires("fastmcp-remote") or [] assert any("fastmcp-slim[client,server]" in req for req in remote_reqs) assert any( ep.name == "fastmcp-remote" and ep.value == "fastmcp_remote.cli:main" for ep in entry_points(group="console_scripts") ) assert build_parser().prog == "fastmcp-remote" PY