Skip to main content
Glama
ryoshu

gas-mcp

by ryoshu
README.md
# gas-mcp

`gas-mcp` is the generic MCP transport for a
`gas_protocol.service.GasService`. It turns one GAS service into an MCP server
without knowing which domain, database, policy implementation, or application
created that service.

## What it provides

`install_gas_mcp(server, service)` registers five structured-output MCP tools:

- `create_session` — create an isolated session and return its initial view.
- `get` — read a resource URI and its contextual commands and links.
- `search` — search a resource collection.
- `act` — execute an advertised capability with a revision and idempotency key.
- `why_not` — diagnose an unavailable command without returning an executable
  command.

The installer adds read-only or mutation tool annotations and translates
`GasError` failures into MCP errors. Domain-specific resource names and input
schemas stay in the `GasBackend` and its composition root.

The package provides transport only. The GAS request/response contract and
capability semantics remain defined by `gas-protocol`; authorization and
domain policy remain with the backend or application that supplies the
service.

## Install

```bash
pip install "gas-mcp[mcp]"
```

The `mcp` extra supplies the MCP SDK needed to import and run the transport.

## Example

```python
from mcp.server import MCPServer

from gas_mcp import install_gas_mcp
from gas_protocol import GasService, InMemoryGasBackend

server = MCPServer(name="example")
install_gas_mcp(server, GasService(InMemoryGasBackend()))
```

For a real application, construct the `GasService` over its own backend and
keep domain-specific MCP resources in that application's composition root.

## Contributing

```bash
uv build
uv run --extra mcp --with pytest pytest -q
```