Skip to content

About

GitHub Pull Request Review. Use GitHub with PydanticAI and Weavz MCP for bounded app reads, typed reports with source references, and synthetic local tests.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GitHub MCP agent with PydanticAI: GitHub Pull Request Review

Use GitHub with PydanticAI through Weavz MCP. This github pull request review example returns a report from bounded app reads with source references.

Framework: PydanticAI · Language: Python · MCP modes: Tool Mode and Code Mode

Use another framework:

MCP app and framework directory · All examples · Weavz MCP guide

Review the selected pull request and its changed-file patches. Summarize behavior changes, test evidence, and concrete review risks tied to file paths; do not merge or comment.

This read-only assistant connects PydanticAI to Weavz through its native MCP adapter. It returns a typed report with findings, metrics, source IDs, links, and explicit gaps. The agent discovers the tools available to its assigned end user; it does not call app providers directly.

Try it locally

Install Python 3.11–3.13 and uv, then run:

uv sync --locked
uv run pytest
uv run python main.py --fixture --mode tools
uv run python main.py --fixture --mode code

Both paths run a real PydanticAI agent loop and authenticated local Streamable HTTP MCP connection. The deterministic model makes actual MCP calls and derives metrics from the returned synthetic records. It uses no paid model or real account. The fixture's normalized records are test data, not a promise about a provider's response format. Code Mode accepts only the fixed fixture read script; it does not evaluate arbitrary code.

App access

Configure these apps in the intended Weavz workspace, then connect credentials for the end user who will run the task. Aliases below are readable examples. Live aliases and available actions come from your server.

Example alias App Read action
code_review github get_pull_request
code_review github custom_api_call

Read the pull request by repository and pull number, then retrieve its changed-file list and patches through the read-only GitHub pull-files endpoint. Do not rely on issue search alone. Review only the returned files and patch context, state when patch text is missing or truncated, and do not claim a full codebase review. Do not create reviews, comments, commits, or merge the PR.

The live agent must retrieve necessary content after a search, respect pagination, and disclose the actual task bounds, relevant date window, and sampled records. These examples do not claim a complete account-wide audit. They do not send replies or modify external records.

Connect your agent

Use an existing custom MCP endpoint and its end-user MCP access token, or create one with the included customer SDK helper. The helper is a trusted-backend operation: it creates an end user if missing, creates a restricted server if no server ID is supplied, and issues a one-hour token. It never changes an existing server's mode or deletes resources.

# Set WEAVZ_API_KEY in your local environment. Keep it on your trusted backend.
uv run python setup_weavz.py \
  --workspace-id 00000000-0000-4000-8000-000000000001 \
  --end-user-id example-user --mode code

Replace the example UUID and user ID with your selected workspace and trusted application user. To reuse a server, add --server-id <server-uuid>. The helper refuses to overwrite its private .env.weavz file. Check resources before retrying a partially completed setup. Keep the REST API key out of agent prompts, MCP headers, and client bundles.

Set your model provider key locally and replace your-model-id with a model available to your account, then run:

WEAVZ_MODEL=openai:your-model-id uv run --env-file .env.weavz python main.py --mode code

Alternatively copy .env.example to .env, fill in your custom MCP URL, token and model credentials, then use uv run --env-file .env python main.py. Use --mode tools with a Tool Mode endpoint. The flag validates the expected catalog; it does not change server configuration.

The hosted personal connector /mcp/weavz uses client OAuth. This bearer example uses a custom endpoint; never substitute a wvz_ REST API key for an MCP access token.

Choose your task inputs

The fixture uses these synthetic inputs:

{
  "repository": "example-org/demo-api",
  "pull_number": 42
}

For live use, save your non-secret scope in .local/inputs.json and run:

uv run --env-file .env.weavz python main.py --inputs .local/inputs.json --prompt "Review the selected pull request and its changed-file patches. Summarize behavior changes, test evidence, and concrete review risks tied to file paths; do not merge or comment."

Supply real IDs and task bounds, including a current date range when the task is time scoped. Retrieved content is data, never agent instructions. A missing connection or pending approval must produce needs_connection or needs_approval, with a recovery explanation. Reports reject invented source IDs and URLs that were not returned by MCP; factual interpretation still needs human review.

Files and checks

  • main.py: CLI, live configuration, local test setup.
  • engine.py: native MCP toolset, agent loop, typed report, evidence checks.
  • scenario.json: task instructions, synthetic records, expected derived metrics.
  • tests/: both MCP modes, report validation, and citation checks.
  • fixture/: isolated synthetic server with its own dependency lock.
  • setup_weavz.py: optional customer SDK setup; no provider credentials are embedded.

Local and CI tests establish fixture interoperability. A live Weavz account, app authorization, and model-provider run are separate checks. See the example directory for other frameworks and clients, and Weavz docs for current setup guidance.

MIT. See LICENSE.

About

GitHub Pull Request Review. Use GitHub with PydanticAI and Weavz MCP for bounded app reads, typed reports with source references, and synthetic local tests.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages