Skip to main content
Glama
JayTheSkier

Fedlex Connector

by JayTheSkier

Fedlex Connector

Access Swiss Federal Law from Claude

A connector that gives Claude direct access to the official text of Swiss federal legislation on Fedlex, built on the Model Context Protocol (MCP). Covers all acts in the Classified Compilation (SR, RS) in German, French, and Italian.


Why This Exists

Swiss federal law is published exclusively on Fedlex, but the frontend is a JavaScript single-page application that Claude's built-in web tools cannot render. However, Fedlex exposes two machine-readable interfaces that work without JavaScript:

  • A SPARQL endpoint (fedlex.data.admin.ch/sparqlendpoint) for metadata queries

  • A static HTML filestore (fedlex.admin.ch/filestore/...) serving consolidated legislation

This MCP server bridges the gap: it queries SPARQL for metadata (RS numbers, consolidation dates, amendment history), fetches and parses the HTML for the actual legislative text, and returns it to Claude in a structured format. No proprietary database, no cache -- just a stateless bridge to Fedlex's open data infrastructure.


Related MCP server: Swiss Data Protection MCP

Setup

The server supports two transports: stdio for local use (Claude Code, Claude Desktop) and HTTP for remote use (claude.ai). You can use one or both.

The server is hosted at:

https://mcp.fedlex-connector.ch

claude.ai / Claude Desktop:

  1. Go to claude.ai

  2. Click Customize (Anpassen / Personnaliser / Personalizza) in the sidebar

  3. Click Connectors

  4. Click +Add connector

  5. Click Add custom connector and paste the URL: https://mcp.fedlex-connector.ch

We suggest naming it "Fedlex Connector".

Claude Code:

claude mcp add --transport http fedlex https://mcp.fedlex-connector.ch

Once connected, Claude can answer questions like "What does art. 1 of the Swiss Civil Code say?" by pulling the text directly from Fedlex.

Deploying Your Own Instance

The server includes a Dockerfile for deploying to any cloud platform that supports Docker containers (Railway, Fly.io, Render, etc.). Set the PORT environment variable and the server runs in HTTP mode. Without PORT, it runs in stdio mode for local use.

Your MCP endpoint will be at https://your-domain. Verify with:

curl https://your-domain/health

Tools

search_by_title

Search Swiss federal legislation titles in the Classified Compilation (RS/SR). Returns only acts currently in force.

Parameter

Type

Required

Description

query

string

Yes

Keywords to match against act titles

language

fr de it

No

Language for results (default: de)

Example: Find the RS number for the data protection act.

search_by_title(query="protection des données")
→ RS 235.1 — Loi fédérale sur la protection des données (LPD)

get_article

Retrieve the official consolidated text of a specific article.

Parameter

Type

Required

Description

rs_number

string

Yes

RS number (e.g. "210" for CC, "220" for CO)

article

string

Yes

Article number (e.g. "3", "28a", "260bis")

language

fr de it

No

Language (default: de)

date

string

No

Consolidation date (YYYY-MM-DD); defaults to latest

Example: Retrieve art. 1 CC in German.

get_article(rs_number="210", article="1", language="de")
→ Art. 1: Das Gesetz findet auf alle Rechtsfragen Anwendung...

get_law_text

Retrieve the full text of an act or a specific title/chapter. This is the primary tool for reading and analysing legislation from the source.

Parameter

Type

Required

Description

rs_number

string

Yes

RS number

section

string

No

Limit to a title/chapter (e.g. "Titre huitième")

language

fr de it

No

Language (default: de)

page

number

No

Page for paginated results (default: 1)

Large acts are paginated automatically (splitting at article boundaries). Each response includes the total page count.

Example: Retrieve Swiss tenancy law (CO, Title 8).

get_law_text(rs_number="220", section="Titre huitième", language="fr")
→ [Full text of tenancy provisions, art. 253 onwards]

list_amendments

List recent amendments (consolidation versions) for a given act.

Parameter

Type

Required

Description

rs_number

string

Yes

RS number

since

string

No

Start date, YYYY-MM-DD (default: 1 year ago)

language

fr de it

No

Language for titles (default: de)

Example: Check recent changes to the CO.

list_amendments(rs_number="220", since="2024-01-01")
→ 2026-01-01 — Version in force from 2026-01-01 (current)
  2025-10-01 — Version in force from 2025-10-01 to 2025-12-31
  ...

How It Works

Claude  ──MCP──>  Fedlex Connector  ──SPARQL──>  fedlex.data.admin.ch
                                      ──HTTP───>   fedlex.admin.ch/filestore/...

Metadata path (SPARQL): The server queries Fedlex's SPARQL endpoint (JOLux ontology) to resolve RS numbers to internal URIs, find the latest consolidation date, discover HTML file URLs, and list amendment history.

Text path (HTML filestore): Once the server knows which HTML file(s) to fetch, it retrieves them from the static filestore, parses the DOM with Cheerio, and extracts the requested article, section, or full text. Large acts (like the CO with 1,100+ articles) are split across multiple HTML files which the server discovers and stitches together automatically.

Data flow for a typical request:

  1. Claude calls get_article(rs_number="210", article="3")

  2. Server queries SPARQL: RS 210 → ConsolidationAbstract URI

  3. Server queries SPARQL: latest consolidation date for that URI

  4. Server queries SPARQL: HTML filestore URL(s) for that consolidation

  5. Server fetches HTML, parses it, extracts art. 3

  6. Server returns the article text to Claude with consolidation date and legal caveat

Every response includes a footer noting that only the Official Compilation (RO/AS) published by the Federal Chancellery is legally authoritative.


Development

Project Structure

src/
  index.ts       # Entry point: picks stdio or HTTP transport based on PORT env var
  server.ts      # MCP server factory: tool definitions and request handlers
  types.ts       # TypeScript interfaces, error types, constants
  sparql.ts      # SPARQL endpoint queries (metadata, RS resolution, amendments)
  filestore.ts   # HTML fetching, parsing, article/section extraction, pagination
build/           # Compiled JavaScript (generated by tsc)
Dockerfile       # Container build for cloud deployment

Scripts

Command

Description

npm run build

Compile TypeScript to ./build

npm start

Run the MCP server (stdio mode)

npm run start:http

Run locally in HTTP mode on port 3000

npm run dev

Watch mode (auto-recompile on changes)

Dependencies

Package

Purpose

@modelcontextprotocol/sdk

MCP server SDK (tool registration, stdio transport)

cheerio

HTML parsing for extracting legislative text

Error Codes

The server returns structured errors with codes and actionable suggestions:

Code

Meaning

RS_NOT_FOUND

RS number not found in the SPARQL graph

ARTICLE_NOT_FOUND

Article does not exist in the act (with nearby IDs listed)

SPARQL_UNAVAILABLE

SPARQL endpoint is down or returned an error

FILESTORE_ERROR

HTML file not found or fetch failed

INVALID_INPUT

Missing or malformed parameters

PARSE_ERROR

HTML parsing failure


Known Limitations

  • Full act historical versions: get_law_text only retrieves full acts as they are currently in force and does not return past versions. For historical text, use get_article, which supports a date parameter.

  • HTML availability: Fedlex generally only provides HTML for consolidations from 2021 onwards. Older versions are only available as PDF or DOC on the Fedlex platform. The server returns a clear error with guidance when HTML is unavailable for a requested date.

  • Rate limiting: The SPARQL endpoint and filestore are public Swiss government services. The server limits itself to 10 requests/second per endpoint to be a responsible client.

  • Section filtering: The section parameter in get_law_text uses heading-text matching which works well for standard section names but may not match unusual headings. When filtering fails, the full act text is returned with a note.

  • Language coverage: Supports French (FR), German (DE), and Italian (IT). Romansch is not available.

  • Scope: Covers federal law in the Classified Compilation only. Cantonal law, the Federal Gazette, and court decisions are out of scope.


License

MIT

Available Tools

4 tools
get_articleAInspect

Retrieve a single article when you already know the EXACT article number (e.g. from a cross-reference). Do NOT call this tool repeatedly to search for provisions — use get_law_text instead to fetch the full act or a section and locate relevant articles in the text.

ParametersJSON Schema
NameRequiredDescriptionDefault
dateNoConsolidation date in YYYY-MM-DD format. Defaults to the latest available version.
articleYesArticle number (e.g. '3', '28a', '41')
languageNoLanguage (default: de)
rs_numberYesRS/SR number (e.g. '210' for CC, '220' for CO, '311.0' for CP)

TDQS

A4.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool returns a single article and that repeated calls are inappropriate for searching. However, it does not describe the return format, error behavior for invalid article numbers, or versioning behavior beyond the date parameter's schema description. The description provides moderate behavioral context but leaves room for more.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, both earning their place. The first states the tool's purpose and the key precondition (exact article number), and the second provides critical usage prohibition and routing to the alternative. No fluff, perfectly front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple single-article retrieval tool with 100% schema coverage, the description covers the essential context: exact-number precondition, the search disincentive, and the alternative routing. The only gaps are the absence of any return-format or error-handling description, but for such a focused tool with a well-documented schema, this is a minor omission.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all four parameters are documented in the schema itself. While the description doesn't add parameter-level detail beyond the schema, it provides essential semantic context: that 'article' must be an exact number from a cross-reference, which clarifies the precision requirement. This adds value beyond the schema's generic description of article as just 'Article number'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves a single article when the exact article number is known, using a specific verb ('Retrieve') and resource. It also differentiates from the sibling tool get_law_text by explicitly stating what it is NOT for, which makes its purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use guidance ('when you already know the EXACT article number'), an explicit when-not-to-use instruction ('Do NOT call this tool repeatedly to search for provisions'), and names the alternative tool (get_law_text) with guidance on how to use it instead. This is exemplary usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_law_textAInspect

Retrieve the official consolidated text of a Swiss federal act (or a specific title/chapter) directly from Fedlex (fedlex.admin.ch). This is the PRIMARY tool for answering Swiss law questions — always start here. Fetch the full act or a specific section, then locate relevant provisions in the returned text. Prefer this over get_article unless you already know the exact article number.

ParametersJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for paginated results (default: 1). Large acts are split across multiple pages.
sectionNoLimit to a specific title, chapter, or part (e.g. 'Titre huitième', 'Zweiter Teil'). If omitted, returns the full act.
languageNoLanguage (default: de)
rs_numberYesRS/SR number (e.g. '210' for CC, '220' for CO)

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does well: it clarifies that the tool fetches official consolidated text, can target a full act or a section, and instructs the agent to 'locate relevant provisions in the returned text.' It does not describe error cases or rate limits, but this is a read-only retrieval tool and the core behavior is clearly disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose. It contains a small amount of redundancy—'Fetch the full act or a specific section' partially repeats the first sentence and the schema—but each sentence still contributes useful usage or workflow context, so it earns a score above baseline.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given four parameters, a full schema, and no output schema, the description provides enough context to call the tool correctly: source, primary use case, section behavior, and how to process the returned text. It does not mention fallback to search_by_title when rs_number is unknown, but the schema and sibling list make this recoverable.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3; the schema already explains rs_number, section, language, and page with examples. The description adds minor reinforcement by mentioning 'specific title/chapter' and 'full act or a specific section,' but it does not materially extend the parameter meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb-resource pair: 'Retrieve the official consolidated text of a Swiss federal act' and names the exact source, Fedlex. It further distinguishes this tool from siblings by declaring itself the 'PRIMARY tool for answering Swiss law questions' and explicitly prefers it over get_article unless an exact article number is known.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives direct when-to-use guidance: 'always start here' for Swiss law questions, and states the condition for choosing get_article instead ('unless you already know the exact article number'). This is explicit enough for an agent to route correctly without opening other tool schemas.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_amendmentsAInspect

List consolidation version dates for a Swiss federal act. Returns the dates each consolidated version took effect.

ParametersJSON Schema
NameRequiredDescriptionDefault
sinceNoStart date in YYYY-MM-DD format (default: 1 year ago)
languageNoLanguage for amendment titles (default: de)
rs_numberYesRS/SR number

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the behavioral disclosure burden. It states the return nature (dates) but says nothing about read-only behavior, authorization requirements, pagination, or side effects. For a listing tool this is a moderate gap, not a critical one.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences with zero waste. The action and result are front-loaded, and every sentence contributes meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with one required parameter and no output schema, the description covers action, resource, and result. It lacks detail on output format and how language/since affect results, but those are documented in the schema, so the definition is largely sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema already describes all three parameters with 100% coverage, so the baseline is 3. The description adds no parameter-specific semantics beyond the schema, though the phrase 'consolidated version dates' loosely contextualizes rs_number and since.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('List') and resource ('consolidation version dates for a Swiss federal act') and clarifies the output ('the dates each consolidated version took effect'). This clearly distinguishes it from siblings like search_by_title or get_article.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives, and no exclusions or conditions are provided. The intended use is only implied by the description's statement of what it returns.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_by_titleAInspect

Search Swiss federal legislation titles in the Classified Compilation (RS/SR) on Fedlex. Use to find the RS number of a law when you know its name but not its number. Searches titles only, not article content. Returns only acts currently in force.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesKeywords to match against act titles (e.g. 'code civil', 'protection des données')
languageNoLanguage for results (default: de)

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses important behaviors beyond the bare operation: it matches titles only, excludes article content, and filters to acts currently in force. It does not describe result format or pagination, but for a simple search tool the core behavioral traits are well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences with no fluff. It front-loads the action and domain, then adds the key differentiator and result filtering. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description covers the main facts an agent needs: what is searched, why to use it, what is excluded, and the in-force filter. It could mention result fields or language behavior in more detail, but the tool is simple and the description is largely sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already explains both query and language parameters, including an example and the default language. The description adds no parameter-level semantics beyond what the schema provides, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Search'), a specific resource ('Swiss federal legislation titles in the Classified Compilation (RS/SR) on Fedlex'), and a clear intended outcome ('find the RS number of a law'). It also distinguishes itself from content search by saying it searches titles only, which differentiates it from siblings like get_article.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says when to use it: when you know a law's name but not its RS number. It also states what it does not do ('Searches titles only, not article content') and that it returns only in-force acts, which are useful exclusions. It does not explicitly name alternative sibling tools, so it stops short of a perfect 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv1.0.0
    • First observedget_article
    • First observedget_law_text
    • First observedlist_amendments
    • First observedsearch_by_title

TDQS

A4.1/5.0
Disambiguation5/5

Each tool has a clear, distinct purpose: searching by title, listing version dates, fetching an exact article, and retrieving full law text. The descriptions explicitly steer agents away from using get_article when get_law_text is more appropriate.

Naming Consistency4/5

list_amendments, get_article, and get_law_text all follow a clean verb_noun pattern. search_by_title is a minor deviation with the preposition 'by', but it remains predictable and readable.

Tool Count5/5

Four tools is well-scoped for a legal retrieval connector: discover a law, fetch its text, fetch a specific article, and check amendment dates. Each tool earns its place with no redundant overlap.

Completeness4/5

The core Swiss law research workflow is covered: find an act by title, retrieve the consolidated text, get a specific article, and list version dates. Missing historical version text retrieval and full-text cross-law search are minor gaps rather than blocking issues.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JayTheSkier/fedlex-connector'

If you have feedback or need assistance with the MCP directory API, please join our Discord server