Skip to main content
Glama
automatikstudio

LegalForge MCP Server

README.md
# LegalForge MCP Server

Model Context Protocol (MCP) server for generating professional legal documents using AI.

## Features

- **Privacy Policy** - GDPR/CCPA compliant privacy policies
- **Terms of Service** - Comprehensive terms for your website/app
- **Cookie Policy** - Detailed cookie policies with consent info

## Installation

```bash
npm install
npm run build
```

## Configuration

Set your Anthropic API key:

```bash
export ANTHROPIC_API_KEY=sk-ant-...
```

## Usage

### Claude Desktop

Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "legalforge": {
      "command": "node",
      "args": ["/path/to/legalforge-mcp/dist/index.js"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}
```

### Programmatic

```bash
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"generate_legal_document","arguments":{"documentType":"privacy","parties":[{"name":"Acme Inc","role":"company","email":"legal@acme.com"}],"terms":{"websiteUrl":"https://acme.com","siteName":"Acme","services":"Google Analytics, Stripe, Intercom"},"jurisdiction":"California, USA"}}}' | node dist/index.js
```

## Tool: generate_legal_document

### Inputs

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `documentType` | `"privacy"` \| `"terms"` \| `"cookie"` | ✓ | Type of legal document |
| `parties` | `Party[]` | ✓ | Parties involved (company, users) |
| `terms` | `Record<string, string>` | ✓ | Document configuration |
| `jurisdiction` | `string` | ✓ | Legal jurisdiction |

### Party Object

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | `string` | ✓ | Party name |
| `role` | `"company"` \| `"user"` \| `"provider"` | ✓ | Role |
| `address` | `string` | - | Physical address |
| `email` | `string` | - | Contact email |

### Terms Object

| Key | Description |
|-----|-------------|
| `websiteUrl` | Website URL |
| `siteName` | Display name for the site |
| `services` | Comma-separated list of services/technologies |

### Output

Returns HTML document content (starting from `<h2>` tags).

## Example

```javascript
const result = await mcpClient.callTool("generate_legal_document", {
  documentType: "privacy",
  parties: [
    {
      name: "TechStartup Inc",
      role: "company",
      email: "privacy@techstartup.com"
    }
  ],
  terms: {
    websiteUrl: "https://techstartup.com",
    siteName: "TechStartup",
    services: "Google Analytics, Stripe, AWS, Intercom"
  },
  jurisdiction: "European Union"
});

console.log(result.content[0].text); // HTML privacy policy
```

## Development

```bash
npm run dev  # Run with tsx (hot reload)
npm run build  # Compile TypeScript
npm start  # Run compiled version
```

## Template Usage

This MCP server serves as a template for building other MCP servers. Key patterns:

1. **Tool registration** with Zod schemas for validation
2. **Prompt engineering** with structured templates
3. **Error handling** with proper MCP error responses
4. **Clean TypeScript** setup with ESM modules

## License

MIT

TDQS

B3.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'generate_legal_document' has a clear and distinct purpose.

Naming Consistency5/5

Since there is only one tool, naming consistency is inherently perfect. The tool name follows a clear verb_noun pattern (generate_legal_document).

Tool Count2/5

A single tool is too few for a server named 'LegalForge MCP Server', which suggests a broader legal domain. This feels thin and incomplete for generating legal documents, as it lacks supporting tools like editing, reviewing, or managing templates.

Completeness2/5

The tool surface is severely incomplete for legal document generation. While 'generate_legal_document' covers creation, there are obvious gaps such as updating, deleting, listing, or customizing documents, which are essential for a full workflow.