-
-
Notifications
You must be signed in to change notification settings - Fork 1
MCP server instrumentation and repositories interface cleaning #61
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7af9cc4
adds fastmcp dep
GabrielBarberini f229eb0
adds AI agent instructions
GabrielBarberini 442983a
CHORE: simplify repository initialization locks
GabrielBarberini a196315
CHORE: migrate repositories to async pymongo client
GabrielBarberini e11ab83
instrument mcp server
GabrielBarberini f18358b
extend mcp tests
GabrielBarberini 721b481
enables experimental open api parser
GabrielBarberini 6500475
fix mcp<>rest bridge
GabrielBarberini 326db29
📝 Add docstrings to `mcp_server` (#62)
coderabbitai[bot] f2ddd2e
removes unnecessary hybrid lifespan
GabrielBarberini 9860f5a
removes unused log import
GabrielBarberini 64d8c80
instrument bundled app
GabrielBarberini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Module Organization | ||
| Source code lives in `src/`, with FastAPI entrypoints in `src/api.py` and domain layers grouped by concern (`controllers/`, `services/`, `repositories/`, `models/`, `routes/`, `views/`). Shared settings and helpers sit in `src/settings/` and `src/utils.py`. Tests mirror this layout under `tests/unit/` and `tests/integration/` for focused and end-to-end coverage. Deployment assets stay at the root (`Dockerfile`, `compose.yaml`, `Makefile`), while virtualenv tooling is kept in `infinity_env/`. | ||
|
|
||
| ## Build, Test, and Development Commands | ||
| - `python3 -m pip install -r requirements.txt` prepares runtime dependencies; add `requirements-dev.txt` for local tooling. | ||
| - `make format` runs Black and Ruff autofixes across `src/` and `tests/`. | ||
| - `make lint` executes Flake8 and Pylint with the repository presets. | ||
| - `make test` wraps `pytest` with the configured `tests/` path. | ||
| - `make dev` starts Uvicorn on `http://localhost:3000` with hot reload. | ||
| - `docker-compose up --build -d` (from `compose.yaml`) builds and runs the API plus MongoDB in containers; use `make clean` to prune stacks. | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
| Target Python 3.12 and a 79-character line length (Black, Ruff, and Pylint enforce this). Prefer module-level functions in `snake_case`, classes in `PascalCase`, and constants in `UPPER_SNAKE_CASE`. Keep FastAPI routers named `<feature>_router` inside `src/routes/`, and align Pydantic models with `CamelCase` class names under `src/models/`. Run `make format` before opening a PR to avoid stylistic churn. | ||
|
|
||
| ## Testing Guidelines | ||
| Pytest drives both unit and integration suites; name files `test_<feature>.py` and group fixtures near usage. Place pure-function tests in `tests/unit/` and API or database flows in `tests/integration/`. Execute `pytest tests/integration/test_environment.py -k simulate` to target scenarios while keeping `--import-mode=importlib` behavior intact. New features should include happy-path and failure-case coverage, plus integration smoke tests when touching MongoDB writes. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| Git history favors concise, uppercase prefixes (`BUG:`, `ENH:`, `MNT:`) followed by a short imperative summary and optional issue reference, e.g. `ENH: streamline rocket encoders (#58)`. Squash commits that fix review feedback before merging. Pull requests should describe intent, list API or schema changes, link to tracking issues, and attach screenshots or sample responses when observable behavior shifts. | ||
|
|
||
| ## Security & Configuration Tips | ||
| Never commit `.env` or credentials; instead, document required keys such as `MONGODB_CONNECTION_STRING` in the PR. Use `src/secrets.py` helpers for secret access rather than inlining values, and prefer Docker secrets or environment variables when deploying. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """FastMCP integration helpers for Infinity API.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from fastapi import FastAPI | ||
| from fastmcp import FastMCP, settings | ||
|
|
||
|
|
||
| def build_mcp(app: FastAPI) -> FastMCP: | ||
| """ | ||
| Create or return a cached FastMCP server that mirrors the given FastAPI app. | ||
|
|
||
| Parameters: | ||
| app (FastAPI): FastAPI application to mirror; the created FastMCP instance is cached on `app.state.mcp`. | ||
|
|
||
| Returns: | ||
| FastMCP: The FastMCP instance corresponding to the provided FastAPI app. | ||
| """ | ||
|
|
||
| if hasattr(app.state, 'mcp'): | ||
| return app.state.mcp # type: ignore[attr-defined] | ||
|
|
||
| settings.experimental.enable_new_openapi_parser = True | ||
GabrielBarberini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mcp = FastMCP.from_fastapi(app, name=app.title) | ||
| app.state.mcp = mcp # type: ignore[attr-defined] | ||
| return mcp | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.