Skip to main content
Glama
README.md
# @pipeworx/pt-law

Portuguese legislation (Decreto-Lei and Lei, from the Diario da Republica) and higher-court decisions (STJ, STA and the five Tribunais da Relacao).

Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 2106+ live data sources. This is an independent, unofficial integration — not affiliated with, endorsed by, or published by the upstream provider.

## Tools

- `pt_dre_get_act(type, number, year, publication_date?)` — resolves a Decreto-Lei or Lei to its Diario da Republica page link. The publication date is optional: without it the number and year are resolved through the Diario da Republica public search (the result says `resolved_via: dre_search`). A wrong number or date returns an explicit `found: false`; an unavailable or changed search returns an error naming the official site.
- `pt_court_search(query, court?, limit?, start?)` — free-text search of court decisions; returns session date, case number, relator, descriptors and a decision link per hit. Empty results carry a `reason`.
- `pt_court_get_decision(url)` — one decision's labelled fields and, where published, the full text.

## Auth

Keyless.

## Data sources

- INCM, Diario da Republica (legislation, European Legislation Identifier resolver).
- Portuguese courts, Bases Juridico-Documentais (DGSI): STJ, STA, TRL, TRP, TRC, TRE, TRG.

Notes

- The identifier scheme needs the publication date, so a number-only call first finds the date through the Diario da Republica public search (anonymous, no login), caches it in the isolate, then resolves the act as usual. Very old acts may not resolve.
- Only Decreto-Lei and Lei are offered, the two act types confirmed against the live resolver.
- The decision database is an old Lotus Domino site. Search pages come back as UTF-8 and decision pages as ISO-8859-1; the pack detects which. Session dates are MM/DD/YYYY upstream and are returned as ISO. Search returns relevance order, not newest first. Full text is online only where the decision's "Texto Integral" field is S.

## Quick Start

Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):

```json
{
  "mcpServers": {
    "pt-law": {
      "url": "https://gateway.pipeworx.io/pt-law/mcp"
    }
  }
}
```

### What this endpoint actually serves

`tools/list` at `https://gateway.pipeworx.io/pt-law/mcp` returns the tools in the table
above **plus five Pipeworx tools**: `ask_pipeworx`, `discover_tools`, `ask_pipeworx_grounded`, `company_register_search` and `company_facts`.
`ask_pipeworx` answers a question this pack does not cover by routing across the
whole catalog, without adding a second MCP server.

Add an option to the same URL:

- `https://gateway.pipeworx.io/pt-law/mcp?meta=1` lists this pack's tools plus **up to 48 shared Pipeworx tools** (48 when this README was
generated; a connection without an account lists fewer, and its own `tools/list` is the
exact answer on any given day).
- `https://gateway.pipeworx.io/pt-law/mcp?meta=0` lists this pack's tools alone.

Or connect to the full Pipeworx gateway to get every pack's tools listed
directly, instead of just this one's:

```json
{
  "mcpServers": {
    "pipeworx": {
      "url": "https://gateway.pipeworx.io/mcp"
    }
  }
}
```

Both URLs reach the same gateway and the same 2106+ data sources. The
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
reaches all of them from either one (it is not listed on a `?meta=0` connection).

## No MCP client? Call it over HTTP

```bash
curl -X POST https://gateway.pipeworx.io/v1/tools/pt_dre_get_act \
  -H 'Content-Type: application/json' \
  -d '{"type":"decreto-lei","number":"10","year":2024,"publication_date":"2024-01-08"}'
```

No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/pt_dre_get_act`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.

## Run it from npm

`@pipeworx/mcp-pt-law` is a local stdio bridge to the Pipeworx gateway: your MCP client
starts it with `npx`, and it forwards every call to the same
`https://gateway.pipeworx.io/pt-law/mcp` endpoint shown above. It needs network access;
there is no offline mode.

```json
{
  "mcpServers": {
    "pt-law": {
      "command": "npx",
      "args": ["-y", "@pipeworx/mcp-pt-law"]
    }
  }
}
```

Without a key it calls anonymously, capped at 50 calls a day. A free account
raises that to 200 a day: get a key at https://pipeworx.io/signup and add
`"env": { "PIPEWORX_API_KEY": "<your key>" }` to the server entry.
The key is sent as a Bearer token, the same way a hosted connection sends it,
so calls are metered and billed exactly as they are there.

It lists **only** this pack's tools by default. Set `PIPEWORX_META_TOOLS=1` to
also list `ask_pipeworx` and the other gateway-wide tools.

Behind an HTTPS proxy: Node's built-in `fetch` does not read `HTTPS_PROXY` by
default. Newer Node releases honour it when `NODE_USE_ENV_PROXY=1` is set; check
your Node version's documentation.

## Using with ask_pipeworx

Instead of calling tools directly, you can ask questions in plain English —
this works on the pack endpoint above as well as on the full gateway:

```
ask_pipeworx({ question: "your question about Pt Law data" })
```

The gateway picks the right tool and fills the arguments automatically.

## More

- [Docs and guides](https://pipeworx.io/docs)
- [pipeworx.io](https://pipeworx.io)

## License

MIT