-
Notifications
You must be signed in to change notification settings - Fork 0
feat: package server and add mkdocs documentation site #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Architecture Overview | ||
|
|
||
| The MCP server orchestrates three subsystems: | ||
|
|
||
| 1. **Transport layer** (`mcp` framework): handles stdio protocol negotiation and tool invocation. | ||
| 2. **GitHub client** (`httpx`): fetches pull-request review comments with retry and pagination safeguards. | ||
| 3. **Git workspace resolver** (`dulwich`): maps the active git repository to a PR URL when one is not provided. | ||
|
|
||
|  | ||
|
|
||
| ## Execution Flow | ||
|
|
||
| 1. MCP host calls `fetch_pr_review_comments`. | ||
| 2. Server resolves the PR URL using the `git_pr_resolver` module when necessary. | ||
| 3. HTTP requests retrieve review comments, applying concurrency and rate limiting. | ||
| 4. Comments are transformed into a markdown specification via the `specs` templates. | ||
| 5. Response returns to the host in the requested format (Markdown or JSON). | ||
|
|
||
| ## Concurrency Model | ||
|
|
||
| The server is asynchronous, relying on `asyncio` to keep HTTP operations non-blocking. HTTP calls use `httpx.AsyncClient` with circuit breakers for GitHub throttling. | ||
|
|
||
| ## Error Handling | ||
|
|
||
| - Expected HTTP failures (401, 403, 404) surface as structured MCP errors for agent awareness. | ||
| - Transient errors trigger retries with exponential backoff and jitter. | ||
| - Uncaught exceptions are logged with stack traces but masked from remote clients to avoid information leakage. | ||
|
|
||
| ## Extensibility | ||
|
|
||
| - Add new MCP tools by registering their schema in `src/mcp_github_pr_review_spec_maker/server.py` and implementing async handlers under `tools/`. | ||
| - Spec generation templates live in `specs/`. Use Markdown with frontmatter metadata for new output formats. | ||
| - Logging integrates with standard `logging` instrumentation. Add adapters to stream to JSON or observability backends. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Changelog | ||
|
|
||
| Document notable changes per release. Follow [Keep a Changelog](https://keepachangelog.com/) format. | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| - Initial migration to MkDocs documentation structure. | ||
| - Planned PyPI packaging with console entry point. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Contributing Guide | ||
|
|
||
| Follow this workflow to submit improvements or bug fixes. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10+ | ||
| - `uv` package manager | ||
| - `pre-commit` | ||
|
|
||
| ## Local Setup | ||
|
|
||
| ```bash | ||
| uv sync --dev | ||
| uv run --extra dev pre-commit install | ||
| uv run --extra dev pre-commit install --hook-type commit-msg | ||
| ``` | ||
|
|
||
| ## Development Loop | ||
|
|
||
| ```bash | ||
| uv run ruff format . | ||
| uv run ruff check --fix . | ||
| uv run mypy . | ||
| make compile-check | ||
| uv run pytest | ||
| ``` | ||
|
|
||
| ## Conventional Commits | ||
|
|
||
| Commit messages must follow [Conventional Commits](https://www.conventionalcommits.org/). Hooks enforce this automatically. | ||
|
|
||
| ## Opening a Pull Request | ||
|
|
||
| 1. Ensure the full quality pipeline passes. | ||
| 2. Update documentation in `docs/` and `CHANGELOG.md` when behaviour changes. | ||
| 3. Link related issues and request review from maintainers. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Configuration | ||
|
|
||
| The MCP server reads configuration from environment variables or a `.env` file in the working directory. Use these controls to tune pagination limits, HTTP behaviour, and GitHub endpoints. | ||
|
|
||
| | Variable | Required | Default | Description | | ||
| | --- | --- | --- | --- | | ||
| | `GITHUB_TOKEN` | ✅ | — | GitHub personal access token scoped to read pull-request comments. | | ||
| | `GH_HOST` | ❌ | `github.com` | GitHub Enterprise hostname. Automatically derives REST/GraphQL endpoints. | | ||
| | `GITHUB_API_URL` | ❌ | `https://{GH_HOST}/api/v3` | Override REST endpoint when the default convention is incorrect. | | ||
| | `GITHUB_GRAPHQL_URL` | ❌ | `https://{GH_HOST}/api/graphql` | Override GraphQL endpoint. | | ||
| | `PR_FETCH_MAX_PAGES` | ❌ | `50` | Maximum pages fetched per PR to prevent runaway pagination. | | ||
| | `PR_FETCH_MAX_COMMENTS` | ❌ | `2000` | Cap on total review comments collected. | | ||
| | `HTTP_PER_PAGE` | ❌ | `100` | GitHub page size. Must be between 1 and 100. | | ||
| | `HTTP_MAX_RETRIES` | ❌ | `3` | Retry budget applied to transient HTTP failures. | | ||
|
|
||
| Store secrets using `.env` in development and delegate to your secrets manager or CI variables in production: | ||
|
|
||
| ```bash | ||
| GITHUB_TOKEN=ghp_... | ||
| PR_FETCH_MAX_COMMENTS=1000 | ||
| ``` | ||
|
|
||
| ### Logging configuration | ||
|
|
||
| Set `LOG_LEVEL` (`DEBUG`, `INFO`, `WARNING`, `ERROR`) to control verbosity. Logs are written to stderr by default and can be directed to a file using the `--log-file` CLI flag. | ||
|
|
||
| ### MPC Manifest overrides | ||
|
|
||
| When packaging for MPC directories, you can bundle default configuration inside `mcp.json`. See [MCP Manifest](../reference/mcp-manifest.md) for schema guidance. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Installation | ||
|
|
||
| The MCP server is published as the Python package `mcp-github-pr-review-spec-maker`. You can install it using `uv`, pip, or integrate it directly into a project that manages dependencies through `pyproject.toml`. | ||
|
|
||
| ## Install with `uv` | ||
|
|
||
| ```bash | ||
| # Add the package to your environment | ||
| uv add mcp-github-pr-review-spec-maker | ||
|
|
||
| # Or install with extras required for development | ||
| uv add mcp-github-pr-review-spec-maker[dev] | ||
| ``` | ||
|
|
||
| ## Install with `pip` | ||
|
|
||
| ```bash | ||
| python -m venv .venv | ||
| source .venv/bin/activate | ||
| pip install mcp-github-pr-review-spec-maker | ||
| ``` | ||
|
|
||
| ## Verify the Entry Point | ||
|
|
||
| After installation, the console script `mcp-github-pr-review-spec-maker` becomes available: | ||
|
|
||
| ```bash | ||
| mcp-github-pr-review-spec-maker --help | ||
| ``` | ||
|
|
||
| This entry point wraps `uv run python -m mcp_github_pr_review_spec_maker.server` when installed from PyPI. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the entry point description accuracy. The documentation states the entry point "wraps Run this script to check the actual entry point definition: 🏁 Script executed: #!/bin/bash
# Check the console script entry point definition in pyproject.toml
rg -A 5 '\[project.scripts\]' pyproject.tomlLength of output: 156 Length of output: 230 Length of output: 42 Length of output: 2477 Fix documentation: entry point does not wrap The documentation incorrectly claims the entry point "wraps 🧰 Tools🪛 LanguageTool[uncategorized] ~31-~31: The official name of this software platform is spelled with a capital “H”. (GITHUB) 🤖 Prompt for AI Agents |
||
|
|
||
| ## Using as a Dependency | ||
|
|
||
| If you are bundling the MCP server inside another project, declare it in your `pyproject.toml`: | ||
|
|
||
| ```toml | ||
| [project] | ||
| dependencies = [ | ||
| "mcp-github-pr-review-spec-maker>=0.2.0", | ||
| ] | ||
| ``` | ||
|
|
||
| The server can then be imported as `mcp_github_pr_review_spec_maker` for programmatic integration or CLI invocation. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Quickstart | ||
|
|
||
| Follow this quickstart to run the MCP server locally with `uv` in under ten minutes. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10 or later | ||
| - [`uv`](https://docs.astral.sh/uv/) package manager (recommended) | ||
| - GitHub personal access token with **read** access to pull requests | ||
|
|
||
| ## Install and Run | ||
|
|
||
| ```bash | ||
| # Clone the project | ||
| uvx git clone https://github.com/petersouter/mcp-github-pr-review-spec-maker.git | ||
| cd mcp-github-pr-review-spec-maker | ||
|
|
||
| # Install runtime dependencies and the editable package | ||
| uv sync | ||
|
|
||
| # Provide credentials | ||
| echo "GITHUB_TOKEN=ghp_your_token" > .env | ||
|
|
||
| # Launch the MCP server over stdio | ||
| uv run mcp-github-pr-review-spec-maker | ||
| ``` | ||
|
|
||
| Once the server is running, connect it from your preferred MCP host (Claude Desktop, Codex CLI, Cursor, etc.). For tailored integration steps, visit [Editor Integrations](../guides/editor-integrations.md). | ||
|
|
||
| ## Verify a Connection | ||
|
|
||
| Use the built-in health command to ensure connectivity: | ||
|
|
||
| ```bash | ||
| claude mcp call pr-review-spec list-tools | ||
| ``` | ||
|
|
||
| Expected response includes `fetch_pr_review_comments` and `resolve_open_pr_url`. | ||
|
|
||
| ## Next Steps | ||
|
|
||
| 1. Review [Security Requirements](../security/index.md) before enabling automated agents. | ||
| 2. Configure `PR_FETCH_MAX_*` environment limits if your repositories have high comment volume. | ||
| 3. Explore [Remote Hosting with `uv`](../guides/remote-uv-endpoint.md) to serve the MCP process over TLS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo: "MPC" should be "MCP".
The heading contains a typo.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents