Skip to main content
Glama
italy-legislation-mcp-server

italy-legislation-mcp-server

by cyanheads
README.md
<div align="center">
  <h1>@cyanheads/italy-legislation-mcp-server</h1>
  <p><b>Search Italian state legislation, read articles by date, and trace amendments via MCP. STDIO or Streamable HTTP.</b>
  <div>7 Tools</div>
  </p>
</div>

<div align="center">

[![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/italy-legislation-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^2.4.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/italy-legislation-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/italy-legislation-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0.2-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.4.4-blueviolet.svg?style=flat-square)](https://bun.sh/)

</div>

<div align="center">

[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/italy-legislation-mcp-server/releases/latest/download/italy-legislation-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=italy-legislation-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvaXRhbHktbGVnaXNsYXRpb24tbWNwLXNlcnZlciJdfQ==) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22italy-legislation-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fitaly-legislation-mcp-server%22%5D%7D)

[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)

</div>

---

## Overview

Search Italian state acts in Normattiva, resolve citations to their Gazzetta Ufficiale publications, and read provisions as originally published or in force on a given date. Browse the current consolidated text, its lifecycle, and changes reported by Normattiva. Searches and source text are in Italian. Coverage is Italian state legislation.

### Tools

| Tool | Description |
|:---|:---|
| `italylaw_search_acts` | Search by Italian words, act type, number, enactment, publication, or validity |
| `italylaw_lookup_citation` | Resolve Italian citations, code aliases, URN:NIR, ELI, and Normattiva links |
| `italylaw_get_provision` | Read an article, comma, or letter in a specified version |
| `italylaw_get_act` | Browse the current act outline or read a selected part |
| `italylaw_list_versions` | List dated act-level events, linked instruments, and parliamentary bills when supplied |
| `italylaw_track_changes` | Find changes reported to consolidated acts and their modifier codes |
| `italylaw_list_reference` | Look up act types, code abbreviations, identifiers, and collection metadata |

## Capability reference

### `italylaw_search_acts` <sub>tool</sub>

Use `query` for Italian words in titles or text, or `title_words` for titles only. Filter by act type, enactment or publication dates, or `in_force_on`. The default page size is 25, with a ceiling of 500. Continue with `next_offset` and the same filters and sort. Results include GU publication coordinates and facets when provided. EU references in titles can carry CELEX identifiers, including legacy references such as `direttiva 95/46/CE` → `31995L0046`.

```json
{"title_words":"procedimento amministrativo","type":"LEGGE","year":1990,"number":241}
```

### `italylaw_lookup_citation` <sub>tool</sub>

Pass citations in `citations`. A resolved entry can include an article address or date selector alongside the publication identity. Use exact GU coordinates to disambiguate candidates. When the call's deadline expires, retry the entries in `unprocessed`.

```json
{"citations":["Legge 7 agosto 1990, n. 241","https://www.normattiva.it/eli/id/1990/08/18/090G0294/ORIGINAL"]}
```

### `italylaw_get_provision` <sub>tool</sub>

Pass exact GU coordinates or a citation and up to 10 article selectors per call. Select a date with `as_of` (a Rome calendar date), or send `original: true` for the text as published. An explicit date and original mode are mutually exclusive. The default is today in Rome. Use `outline: true` to get addressable comma labels. The `((…))` markers identify wording changed or inserted by amendment. Submit any selectors returned as remaining in a follow-up call.

```json
{"act":{"codice_redazionale":"090G0294","data_gu":"1990-08-18"},"provisions":["art. 1, comma 1"],"as_of":"2024-01-01"}
```

### `italylaw_get_act` <sub>tool</sub>

Omit `part` for the current outline. Pass an exact outline path or an unambiguous section, article, preamble, or annex label for text. Use `outline: true` to browse the selected part. Start without polling by setting `wait_seconds: 0`.

```json
{"act":{"codice_redazionale":"090G0294","data_gu":"1990-08-18"},"wait_seconds":0}
```

For a pending export, wait the returned `retry_after_seconds`, then pass its `job_token` in place of `act`. Either export tool can resume the job. Tokens expire and are lost on restart. The default polling window is 45 seconds.

```json
{"job_token":"<job_token from the pending response>"}
```

### `italylaw_list_versions` <sub>tool</sub>

Read dated lifecycle events from the current Akoma Ntoso export, newest first. These dates describe act-level events. Use the provision tool to see which wording was in force for an individual article. Filter with inclusive `from` and `to`, and pass `next_offset` as `offset` to continue. Pass either `act` or a pending `job_token`, using the same continuation flow as `italylaw_get_act`.

```json
{"act":{"codice_redazionale":"090G0294","data_gu":"1990-08-18"},"limit":5}
```

### `italylaw_track_changes` <sub>tool</sub>

Supply both `from` and `to` (inclusive Rome dates) or omit both for the last seven calendar days. Results reflect changes the feed observed within the window. Modifier codes are preserved when a notice has no associated act or a lookup cannot finish. For historical lifecycle events, use `italylaw_list_versions`.

```json
{"from":"2024-01-01","to":"2024-01-31","limit":5}
```

### `italylaw_list_reference` <sub>tool</sub>

Choose `act_types`, `identifiers`, `codes`, `collections`, `coverage`, `errors`, or `all` (default). Collections list metadata about available bulk datasets and require a Normattiva request.

```json
{"topic":"act_types"}
```

## Features

Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core): stdio and Streamable HTTP transports, pluggable auth (`none` / `jwt` / `oauth`), swappable storage (`in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`), structured logging with optional OpenTelemetry tracing.

- Normattiva access requires no API key.
- Verified publication coordinates distinguish an act's identity from its enactment date and the validity of any article.
- Results carry source attribution and continuation fields for pending jobs, partial calls, and paginated queries.

## Getting started

```sh
claude mcp add italy-legislation-mcp-server -- npx -y @cyanheads/italy-legislation-mcp-server
```

For other clients, add this to the MCP config file.

```json
{
  "mcpServers": {
    "italy-legislation-mcp-server": {
      "command": "npx",
      "args": ["-y", "@cyanheads/italy-legislation-mcp-server"]
    }
  }
}
```

Bun users can run `bunx @cyanheads/italy-legislation-mcp-server`. For Docker or a source build, see [Running the server](#running-the-server).

## Configuration

| Variable | Purpose | Default |
|:---|:---|:---|
| `MCP_TRANSPORT_TYPE` | `stdio` or `http` | `stdio` |
| `MCP_HTTP_HOST` | HTTP bind address | `127.0.0.1` |
| `MCP_HTTP_PORT` | HTTP port | `3010` |
| `MCP_HTTP_ENDPOINT_PATH` | MCP endpoint path | `/mcp` |
| `MCP_AUTH_MODE` | `none`, `jwt`, or `oauth` | `none` |
| `MCP_LOG_LEVEL` | Minimum log level | `info` |
| `OTEL_ENABLED` | Enable OpenTelemetry | `false` |
| `MCP_USAGE_REPORTING` | Share a tool-call summary with the maintainer | `false` |

See [`.env.example`](./.env.example) for common framework overrides.

## Running the server

The default local HTTP endpoint is `http://127.0.0.1:3010/mcp`.

```sh
MCP_TRANSPORT_TYPE=http npx -y @cyanheads/italy-legislation-mcp-server
```

### Local development

Requires [Bun v1.4.4](https://bun.sh/) or higher for development. The built npm entry point also runs on Node.js v24+.

```sh
git clone https://github.com/cyanheads/italy-legislation-mcp-server.git
cd italy-legislation-mcp-server
bun install
cp .env.example .env
bun run rebuild
bun run start:http
# or bun run start:stdio
```

### Docker

```sh
docker run --rm -p 127.0.0.1:3010:3010 ghcr.io/cyanheads/italy-legislation-mcp-server:latest
```

The image defaults to HTTP and stateless sessions, with logs in `/var/log/italy-legislation-mcp-server`. For stdio, configure the client with `"command": "docker"` and `"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/italy-legislation-mcp-server:latest"]`. Build locally with `docker build -t italy-legislation-mcp-server .`. Pass `--build-arg OTEL_ENABLED=false` to omit the OpenTelemetry peer dependencies.

## Project structure

| Directory | Purpose |
|:---|:---|
| `src/mcp-server/tools` | Seven tool definitions and shared export schemas |
| `src/services/normattiva` | Normattiva API client, search, provision reads, change feed, and export jobs |
| `src/domain` | Legal citations, identifiers, and parsing of Akoma Ntoso and article HTML |
| `tests/` | Domain, service, and tool tests |

See [the directory tree](./docs/tree.md).

## Development guide

See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules.

- Handlers throw and the framework catches and classifies failures.
- Use `ctx.log` for logging and `ctx.state` for tenant-scoped storage.
- Register tools in `src/index.ts`.
- Validate upstream responses before normalizing to domain types. Omit absent source fields.

## Contributing

Issues are welcome. Run checks and tests before submitting.

```sh
bun run devcheck
bun run test
```

## License

The server is licensed under [Apache 2.0](./LICENSE).

Fonte: Normattiva (www.normattiva.it), Istituto Poligrafico e Zecca dello Stato, CC BY 4.0. The source data are free, non-authentic, and reformatted by this server. The printed Gazzetta Ufficiale prevails. [Normattiva Open Data terms](https://dati.normattiva.it/Dati-disponibili) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)