Skip to content

Latest commit

Β 

History

History
431 lines (342 loc) Β· 12 KB

File metadata and controls

431 lines (342 loc) Β· 12 KB

πŸ›οΈ Federal Legal APIs Monorepo

TypeScript SDKs and MCP servers for U.S. federal legal and regulatory APIs

CI Status Release Status License: MIT GitHub Stars


πŸ“‘ Table of Contents

πŸš€ Quick Start

# Install any SDK
npm install @us-legal-tools/ecfr-sdk
npm install @us-legal-tools/federal-register-sdk
npm install @us-legal-tools/courtlistener-sdk
npm install @us-legal-tools/govinfo-sdk
npm install @us-legal-tools/dol-sdk

# Or clone and run locally
git clone https://github.com/beshkenadze/us-legal-tools.git
cd ecfr-sdk
bun install
turbo build

πŸ“¦ Packages

Package Version Description
@us-legal-tools/ecfr-sdk npm version Electronic Code of Federal Regulations API
@us-legal-tools/federal-register-sdk npm version Federal Register documents and notices API
@us-legal-tools/courtlistener-sdk npm version Legal opinions, PACER data, and judge info API
@us-legal-tools/govinfo-sdk npm version Government Publishing Office documents API
@us-legal-tools/dol-sdk npm version Department of Labor statistics and data API

πŸ“š Key Features

@us-legal-tools/ecfr-sdk - Electronic Code of Federal Regulations

  • Full text of all 50 CFR titles with advanced search
  • Historical versions and change tracking
  • MCP Server: eCFRSDKServer
  • All documents published since 1994 with agency information
  • Public inspection documents before publication
  • MCP Server: FederalRegisterServer
  • Millions of legal opinions from federal and state courts
  • Judge profiles, oral arguments, PACER integration
  • Citation lookup and docket alerts
  • MCP Server: CourtListenerRESTAPIServer
  • Congressional, judicial, and executive branch publications
  • Full-text search with multiple download formats
  • MCP Server: GovInfoServer

@us-legal-tools/dol-sdk - Department of Labor

  • Employment, wages, inflation, and productivity statistics
  • Industry-specific and geographic data
  • MCP Server: DOLDataServer

πŸ“– Usage Examples

eCFR SDK

import { getApiSearchV1Results } from '@us-legal-tools/ecfr-sdk';

// Search for regulations about "clean air"
const results = await getApiSearchV1Results({
  q: 'clean air',
  per_page: 10,
  page: 1
});

console.log(`Found ${results.count} regulations`);
results.results.forEach(result => {
  console.log(`- ${result.title}: ${result.label_string}`);
});

Federal Register SDK

import { getDocumentsFormat } from '@us-legal-tools/federal-register-sdk';

// Search for recent EPA rules
const documents = await getDocumentsFormat({
  format: 'json',
  conditions: {
    agencies: ['environmental-protection-agency'],
    type: ['RULE'],
    publication_date: {
      gte: '2024-01-01'
    }
  }
});

console.log(`Found ${documents.count} EPA rules in 2024`);

CourtListener SDK

import { getSearch } from '@us-legal-tools/courtlistener-sdk';

// Search for Supreme Court cases about free speech
const cases = await getSearch({
  type: 'o', // opinions
  q: 'free speech',
  court: 'scotus',
  order_by: 'score desc'
});

console.log(`Found ${cases.count} Supreme Court cases`);
cases.results.forEach(case => {
  console.log(`- ${case.caseName} (${case.dateFiled})`);
});

GovInfo SDK

import { createApiClient } from '@us-legal-tools/govinfo-sdk';

const client = createApiClient({
  headers: {
    'X-Api-Key': process.env.GOV_INFO_API_KEY
  }
});

// Search for recent legislation
const results = await client.searchPublished({
  query: 'infrastructure',
  pageSize: 10,
  offsetMark: '*',
  collection: 'BILLS'
});

console.log(`Found ${results.data.count} bills about infrastructure`);

DOL SDK

import { createApiClient } from '@us-legal-tools/dol-sdk';

const client = createApiClient({
  headers: {
    'X-API-KEY': process.env.DOL_API_KEY
  }
});

// Get available datasets
const datasets = await client.getDatasets();

console.log(`Available DOL datasets: ${datasets.data.datasets.length}`);
datasets.data.datasets.forEach(dataset => {
  console.log(`- ${dataset.dataset_title}`);
});

πŸ€– MCP (Model Context Protocol) Servers

Each SDK includes an MCP server that enables AI assistants to interact with these APIs. MCP servers provide a standardized way for AI tools to access external data sources.

Running MCP Servers

# Run eCFR MCP Server
cd packages/ecfr-sdk
bun run mcp:server

# Run Federal Register MCP Server
cd packages/federal-register-sdk
bun run mcp:server

# Run CourtListener MCP Server (requires API token)
cd packages/courtlistener-sdk
COURTLISTENER_API_TOKEN=your-token bun run mcp:server

# Run GovInfo MCP Server (requires API key)
cd packages/govinfo-sdk
GOV_INFO_API_KEY=your-key bun run mcp:server

# Run DOL MCP Server (requires API key)
cd packages/dol-sdk
DOL_API_KEY=your-key bun run mcp:server

MCP Integration Example

Configure your AI assistant (like Claude) to use these MCP servers:

{
  "mcpServers": {
    "ecfr": {
      "command": "bunx",
      "args": ["@us-legal-tools/ecfr-sdk/mcp"]
    },
    "federal-register": {
      "command": "bunx", 
      "args": ["@us-legal-tools/federal-register-sdk/mcp"]
    },
    "courtlistener": {
      "command": "bunx",
      "args": ["@us-legal-tools/courtlistener-sdk/mcp"],
      "env": {
        "COURTLISTENER_API_TOKEN": "your-token"
      }
    },
    "govinfo": {
      "command": "bunx",
      "args": ["@us-legal-tools/govinfo-sdk/mcp"],
      "env": {
        "GOV_INFO_API_KEY": "your-key"
      }
    },
    "dol": {
      "command": "bunx",
      "args": ["@us-legal-tools/dol-sdk/mcp"],
      "env": {
        "DOL_API_KEY": "your-key"
      }
    }
  }
}

πŸ”‘ Authentication

CourtListener API

Requires an API token from CourtListener. Set via:

  • Environment variable: COURTLISTENER_API_TOKEN
  • Or pass directly in API calls

GovInfo API

Requires an API key from GovInfo. Set via:

  • Environment variable: GOV_INFO_API_KEY
  • Or pass in request headers

DOL API

Requires an API key from DOL Developer. Set via:

  • Environment variable: DOL_API_KEY
  • Or pass in request headers

eCFR & Federal Register APIs

No authentication required - these are public APIs.

πŸ› οΈ Development

This is a Turborepo monorepo using Bun for package management.

Setup

# Clone the repository
git clone https://github.com/beshkenadze/us-legal-tools.git
cd ecfr-sdk

# Install dependencies
bun install

# Generate all SDKs
turbo generate

# Build all packages
turbo build

# Run tests
turbo test

Project Structure

ecfr-sdk/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ ecfr-sdk/              # eCFR SDK
β”‚   β”œβ”€β”€ federal-register-sdk/  # Federal Register SDK
β”‚   β”œβ”€β”€ courtlistener-sdk/     # CourtListener SDK
β”‚   β”œβ”€β”€ govinfo-sdk/           # GovInfo SDK
β”‚   β”œβ”€β”€ dol-sdk/               # Department of Labor SDK
β”‚   └── tsconfig/              # Shared TypeScript configs
β”œβ”€β”€ turbo.json                 # Turborepo configuration
β”œβ”€β”€ package.json               # Root package.json
β”œβ”€β”€ biome.json                 # Code formatter/linter config
β”œβ”€β”€ tsconfig.json              # Root TypeScript config
└── README.md                  # This file

Adding a New SDK

  1. Create a new package directory: packages/your-sdk
  2. Add orval configuration for OpenAPI code generation
  3. Configure TypeScript and build scripts
  4. Add to root tsconfig.json references
  5. Update this README

πŸ“‹ Commands

# Install dependencies
bun install

# Generate all SDKs from OpenAPI specs
turbo generate

# Build all packages
turbo build

# Run tests
turbo test
turbo test:integration
turbo test:e2e

# Format and lint
turbo format
turbo lint

Working with Packages

# Run a specific package's command
turbo run build --filter=@us-legal-tools/ecfr-sdk

# Work on a specific package
cd packages/ecfr-sdk
bun test

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE for details.

πŸ”— Resources

API Documentation

Websites

MCP Resources

πŸ‘€ Author

Aleksandr Beshkenadze beshkenadze@gmail.com


Built with ❀️ using Turborepo, Bun, and Orval