-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add repository-specific copilot instructions #6
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
2 commits
Select commit
Hold shift + click to select a range
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
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,158 @@ | ||
| # capiscio-mcp-python - GitHub Copilot Instructions | ||
|
|
||
| ## ⛔ ABSOLUTE RULES - NO EXCEPTIONS | ||
|
|
||
| ### 1. ALL WORK VIA PULL REQUESTS | ||
| - **NEVER commit directly to `main`.** All changes MUST go through PRs. | ||
| - Create feature branches: `feature/`, `fix/`, `chore/` | ||
|
|
||
| ### 2. RUN TESTS LOCALLY BEFORE PUSH | ||
| - `pytest -v` must pass before pushing | ||
|
|
||
| ### 3. NO WATCH/BLOCKING COMMANDS | ||
| - **NEVER run blocking commands** without timeout | ||
|
|
||
| --- | ||
|
|
||
| ## 🚨 CRITICAL: Read First | ||
|
|
||
| **Before starting work, check the repo's README.md and existing code patterns.** | ||
|
|
||
| --- | ||
|
|
||
| ## Repository Purpose | ||
|
|
||
| **capiscio-mcp-python** (PyPI: `capiscio-mcp`) is the MCP Guard — tool-level security for Model Context Protocol servers. It implements: | ||
|
|
||
| - **RFC-006**: MCP Tool Authority and Evidence | ||
| - **RFC-007**: MCP Server Identity Disclosure and Verification | ||
|
|
||
| **Current Version**: v2.4.0 | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| capiscio-mcp-python/ | ||
| ├── capiscio_mcp/ | ||
| │ ├── __init__.py # Public API exports | ||
| │ ├── guard.py # @guard decorator — core trust enforcement | ||
| │ ├── server.py # Server verification utilities | ||
| │ ├── registration.py # Server DID generation & registration | ||
| │ ├── pop.py # Proof-of-possession and evidence handling | ||
| │ ├── integrations/ # MCP framework integrations | ||
| │ │ └── mcp.py # CapiscioMCPServer/Client wrappers | ||
| │ ├── types.py # Shared type definitions | ||
| │ └── errors.py # Error classes | ||
| ├── docs/ # MkDocs documentation | ||
| ├── tests/ # Test suite | ||
| └── pyproject.toml # Package configuration | ||
| ``` | ||
|
|
||
| ## Key Concepts | ||
|
|
||
| ### @guard Decorator | ||
|
|
||
| The primary API surface. Wraps MCP tool handlers with trust-level enforcement: | ||
|
|
||
| ```python | ||
| from capiscio_mcp import guard | ||
|
|
||
| @guard(min_trust_level=2) | ||
| async def sensitive_tool(query: str, badge: str) -> str: | ||
| """Only agents with trust level ≥ 2 can call this.""" | ||
| ... | ||
| ``` | ||
|
|
||
| ### FastMCP Integration | ||
|
|
||
| For use with the MCP SDK's FastMCP server: | ||
|
|
||
| ```python | ||
| from capiscio_mcp.integrations.mcp import CapiscioMCPServer | ||
|
|
||
| server = CapiscioMCPServer("my-server", default_trust_level=1) | ||
|
|
||
| @server.tool() | ||
| @guard(min_trust_level=2) | ||
| async def protected_tool(query: str) -> str: | ||
| ... | ||
| ``` | ||
|
|
||
| ### Server Identity | ||
|
|
||
| MCP servers register their own identity (DID) with CapiscIO: | ||
|
|
||
| ```python | ||
| from capiscio_mcp import setup_server_identity, register_server_identity, verify_server | ||
|
|
||
| # Set up this server's identity (generates keys, prepares DID document) | ||
| await setup_server_identity(name="my-mcp-server", url="https://...") | ||
|
|
||
| # Register this server's identity with the CapiscIO registry | ||
| identity = await register_server_identity() | ||
|
|
||
| # Verify another server | ||
| result = await verify_server("did:web:other-server.example.com") | ||
| ``` | ||
|
|
||
| ### Evidence Logging | ||
|
|
||
| Every guarded tool call produces a cryptographic evidence record: | ||
|
|
||
| ```python | ||
| # Evidence is automatically collected by @guard | ||
| # Contains: caller DID, tool name, timestamp, badge JTI, trust level | ||
| ``` | ||
|
|
||
| ## Critical Rules | ||
|
|
||
| ### 1. RFC Compliance | ||
| - RFC-006 defines the evidence format — don't change the schema | ||
| - RFC-007 defines server identity — follow the DID document structure | ||
|
|
||
| ### 2. gRPC Dependency | ||
| Badge verification calls capiscio-core via gRPC. The `CAPISCIO_CORE_ADDR` environment variable must point to the core service: | ||
| ```bash | ||
| CAPISCIO_CORE_ADDR=localhost:50051 # Local development | ||
| ``` | ||
|
|
||
| ### 3. Trust Level Semantics | ||
| - Level 0: Self-signed (no verification) | ||
| - Level 1: Domain validated (DV) | ||
| - Level 2: Organization validated (OV) | ||
| - Level 3: Extended validated (EV) | ||
| - Level 4: Reserved (not yet implemented) | ||
|
|
||
| ### 4. Async-First APIs | ||
| Public APIs are **async-first** — prefer async interfaces. Synchronous wrappers (e.g., `*_sync`) exist for compatibility; do not add new sync wrappers or change existing ones without discussion and clear documentation. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| ```bash | ||
| # Optional: Point to a running capiscio-core gRPC server (default: auto-start local) | ||
| CAPISCIO_CORE_ADDR=localhost:50051 | ||
|
|
||
| # Optional: Filesystem path to capiscio-core binary | ||
| CAPISCIO_BINARY_PATH=/path/to/capiscio-core | ||
| # or set CAPISCIO_BINARY if the binary is on your PATH: | ||
| # CAPISCIO_BINARY=capiscio-core | ||
|
|
||
| # Server origin for evidence logging | ||
| CAPISCIO_SERVER_ORIGIN=http://localhost:8000 | ||
| ``` | ||
|
|
||
| ## Common Commands | ||
|
|
||
| ```bash | ||
| # Install for development | ||
| pip install -e ".[dev,mcp]" | ||
|
|
||
| # Run tests | ||
| pytest -v | ||
|
|
||
| # Build docs | ||
| mkdocs build | ||
|
|
||
| # Type checking | ||
| mypy capiscio_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.
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.
This section says
CAPISCIO_CORE_ADDR“must” point to capiscio-core, but the client supports an embedded mode whenCAPISCIO_CORE_ADDRis unset (auto-download/start core locally). Consider rewording to describe both modes so developers don’t think the env var is required.