@corpuslaw/mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @corpuslaw/mcp-server
2
+
3
+ MCP server giving any AI agent **571,582 provisions of US federal, state and
4
+ municipal law** with verbatim citations — plus a complete LLC / nonprofit
5
+ formation intake.
6
+
7
+ ```bash
8
+ npx -y @corpuslaw/mcp-server
9
+ ```
10
+
11
+ ## Claude Desktop / Cursor / any MCP client
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "corpus-law": {
17
+ "command": "npx",
18
+ "args": ["-y", "@corpuslaw/mcp-server"],
19
+ "env": { "CORPUS_API_KEY": "your-key-here" }
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ `CORPUS_API_KEY` is optional but recommended — [free and instant](https://corpuslaw.us/settings).
26
+ Anonymous access gets 100 searches/month per IP; a free key gets 1,000/month at
27
+ 30/min.
28
+
29
+ > **If your client speaks HTTP MCP**, skip this package entirely and point it
30
+ > straight at `https://corpuslaw.us/api/mcp`. This bridge exists for stdio-only
31
+ > clients.
32
+
33
+ ## Tools
34
+
35
+ `law.search` · `law.get_node` · `law.list_coverage` · `formation.requirements` ·
36
+ `formation.lookup_naics` · `formation.handoff` · `account.status`
37
+
38
+ Formation tools are never metered.
39
+
40
+ ## Environment
41
+
42
+ | Variable | Default | Purpose |
43
+ |---|---|---|
44
+ | `CORPUS_API_KEY` | _(optional)_ | Raises rate limits; attributes formation handoffs to you |
45
+ | `CORPUS_BASE_URL` | `https://corpuslaw.us` | Point at your own deployment |
46
+
47
+ Apache-2.0 · [source](https://github.com/teakesdev/corpus-agent-kit) · [security policy](https://github.com/teakesdev/corpus-agent-kit/blob/main/SECURITY.md)
package/dist/bridge.js ADDED
@@ -0,0 +1,27 @@
1
+ export async function handleMessage(msg, deps) {
2
+ if (!msg || typeof msg !== "object")
3
+ return null;
4
+ if (typeof msg.method === "string" && msg.method.startsWith("notifications/"))
5
+ return null;
6
+ if (msg.method === "ping")
7
+ return { jsonrpc: "2.0", id: msg.id ?? null, result: {} };
8
+ try {
9
+ return await deps.forward(msg);
10
+ }
11
+ catch (err) {
12
+ return { jsonrpc: "2.0", id: msg.id ?? null, error: { code: -32000, message: String(err.message ?? err) } };
13
+ }
14
+ }
15
+ export function makeForward(mcpUrl, apiKey) {
16
+ return async (msg) => {
17
+ const headers = { "Content-Type": "application/json" };
18
+ if (apiKey)
19
+ headers.Authorization = `Bearer ${apiKey}`;
20
+ const res = await fetch(mcpUrl, { method: "POST", headers, body: JSON.stringify(msg) });
21
+ if (!res.ok && res.status !== 202)
22
+ throw new Error(`hosted MCP returned HTTP ${res.status}`);
23
+ if (res.status === 202)
24
+ return null;
25
+ return (await res.json());
26
+ };
27
+ }
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ /** MCP stdio transport: newline-delimited JSON-RPC on stdin/stdout. */
3
+ import { createInterface } from "node:readline";
4
+ import { handleMessage, makeForward } from "./bridge.js";
5
+ const base = process.env.CORPUS_BASE_URL || "https://corpuslaw.us";
6
+ const forward = makeForward(process.env.CORPUS_MCP_URL || `${base}/api/mcp`, process.env.CORPUS_API_KEY);
7
+ const rl = createInterface({ input: process.stdin });
8
+ rl.on("line", async (line) => {
9
+ const trimmed = line.trim();
10
+ if (!trimmed)
11
+ return;
12
+ let msg;
13
+ try {
14
+ msg = JSON.parse(trimmed);
15
+ }
16
+ catch {
17
+ process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } }) + "\n");
18
+ return;
19
+ }
20
+ const res = await handleMessage(msg, { forward });
21
+ if (res)
22
+ process.stdout.write(JSON.stringify(res) + "\n");
23
+ });
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@corpuslaw/mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "MCP server giving any AI agent 571,582 provisions of US federal, state and municipal law with verbatim citations \u2014 plus LLC/nonprofit formation intake. Thin client of corpuslaw.us.",
5
+ "keywords": [
6
+ "mcp",
7
+ "model-context-protocol",
8
+ "mcp-server",
9
+ "law",
10
+ "legal",
11
+ "legaltech",
12
+ "us-law",
13
+ "statutes",
14
+ "legal-research",
15
+ "business-formation",
16
+ "llc",
17
+ "ai-agents",
18
+ "claude",
19
+ "cursor"
20
+ ],
21
+ "license": "Apache-2.0",
22
+ "author": "Corpus (https://corpuslaw.us)",
23
+ "homepage": "https://github.com/teakesdev/corpus-agent-kit#readme",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/teakesdev/corpus-agent-kit.git",
27
+ "directory": "mcp-server"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/teakesdev/corpus-agent-kit/issues"
31
+ },
32
+ "type": "module",
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "bin": {
37
+ "corpus-mcp": "dist/index.js"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "npm run build && node --test 'test/**/*.test.mjs'",
50
+ "prepublishOnly": "npm run build"
51
+ },
52
+ "devDependencies": {
53
+ "typescript": "^5.6.3",
54
+ "@types/node": "^22.0.0"
55
+ }
56
+ }