Skip to main content

Swagger-like docs UI for FastMCP tools, prompts, and resources.

Project description

mcp-swagger-ui

Upload Python Package

Swagger UI style documentation for MCP FastMCP servers.

Features

Given an mcp.server.fastmcp.FastMCP instance, this package:

  • inspects registered tools, prompts, resources, and resource templates
  • generates an OpenAPI-like JSON document
  • serves the same Swagger UI style as FastAPI /docs
  • shows tool and prompt arguments directly in Swagger parameter lists
  • highlights required vs optional arguments in generated docs
  • supports optional auth for docs endpoints

Installation

pip install mcp-swagger-ui

For local development:

cd mcp_swagger_ui
python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev]"

Quickstart

from fastapi import FastAPI, HTTPException, Header
from mcp.server.fastmcp import FastMCP
from mcp_swagger_ui import mount_mcp_docs

# your FastMCP instance
mcp = FastMCP("My MCP Server")

app = FastAPI()

def docs_auth(x_api_key: str | None = Header(default=None)) -> None:
    if x_api_key != "secret-docs-key":
        raise HTTPException(status_code=401, detail="Unauthorized")

mount_mcp_docs(
    app,
    mcp,
    mount_path="/mcp-docs",
    title="My MCP Server Docs",
    auth_dependency=docs_auth,  # optional
)

Then open:

  • http://localhost:8000/mcp-docs
  • http://localhost:8000/mcp-docs/openapi.json

What The Docs Show

The generated docs are discoverability-focused and currently document:

  • tool descriptions
  • prompt descriptions
  • argument names, types, defaults, and required status
  • response schema summaries when available

Tools, prompts, and resources are grouped by Swagger tags, while the displayed paths use only the item names such as /search_users or /summarize_text.

Testing

This project includes a pytest suite with coverage enforcement.

Release Process

This repository follows an automated open-source release flow:

  • pull requests run CI
  • release preparation happens in a maintainer-controlled release branch
  • release PRs must include version and changelog updates
  • publishing to PyPI happens only from a pushed v* tag that matches the package version on master

Contributor guidance:

  • keep user-facing changes documented in the PR and in docs when needed
  • do not manually edit versions for normal feature PRs unless the work is explicitly release preparation

Maintainer guides:

API

  • mount_mcp_docs(app, mcp, mount_path="/mcp-docs", title="MCP Docs", version="1.0.0", auth_dependency=None) -> None
  • create_docs_router(mcp, title="MCP Docs", version="1.0.0", openapi_path="/openapi.json", auth_dependency=None) -> APIRouter

Compatibility

  • FastMCP API alignment:
    • Uses official server methods first: list_tools(), list_prompts(), list_resources(), list_resource_templates()
    • Handles async and sync method returns
    • Uses converter helpers (to_mcp_tool(), to_mcp_prompt(), to_mcp_resource()) when available
  • A generic fallback introspection path is still present for compatibility with FastMCP-adjacent objects.
  • The generated schema is OpenAPI-like and focused on discoverability/documentation.
  • Tool execution against an already-mounted MCP JSON-RPC endpoint is not implemented in this package yet.

Important

  • This package targets the mcp SDK FastMCP import path:
    • from mcp.server.fastmcp import FastMCP
  • If you are using standalone fastmcp, this package will still usually work due to API overlap.

Publishing

Publishing is automated from GitHub Releases via GitHub Actions.

Initial repository setup still requires:

  • configuring PyPI Trusted Publishing for this repository
  • optionally protecting the pypi GitHub environment

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_swagger_ui-0.1.3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

mcp_swagger_ui-0.1.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_swagger_ui-0.1.3.tar.gz.

File metadata

  • Download URL: mcp_swagger_ui-0.1.3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_swagger_ui-0.1.3.tar.gz
Algorithm Hash digest
SHA256 87d2fd6e012b98c24eaf4427e4e1b2bb11a017bf27d2bc97ce0bed1070583e71
MD5 51061a79b4a12c45ac08a12ab08ba940
BLAKE2b-256 b9fd465d2570b99c4c208bd79f539a86eefa0e6c4c0417fc06ae1c6b1633f8ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_swagger_ui-0.1.3.tar.gz:

Publisher: python-publish.yml on VasuDevAiNamaha/mcp_swagger_ui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_swagger_ui-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mcp_swagger_ui-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_swagger_ui-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19bc5299bdb8155b2cf2e7863abaa0f34122099b62192e0d352949ef85a5e5f7
MD5 dcb2c0e050f379bed3e3fd49e83ff184
BLAKE2b-256 66dba4a7ebc023d335ace1d809353b95cbb418cdd2443d08f289a23342ef6d1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_swagger_ui-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on VasuDevAiNamaha/mcp_swagger_ui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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