@pipeworx/mcp-open-sanctions 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # mcp-open-sanctions
2
+
3
+ OpenSanctions MCP — Global sanctions and PEP data (free, no auth required)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 965+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "open-sanctions": {
20
+ "url": "https://gateway.pipeworx.io/open-sanctions/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 965+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Open Sanctions data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-open-sanctions",
3
+ "version": "0.1.0",
4
+ "description": "OpenSanctions MCP — Global sanctions and PEP data (free, no auth required)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "open-sanctions"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-open-sanctions"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/open-sanctions",
4
+ "title": "Open Sanctions",
5
+ "description": "OpenSanctions MCP — Global sanctions and PEP data (free, no auth required)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/open-sanctions",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-open-sanctions",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/open-sanctions/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,161 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * OpenSanctions MCP — Global sanctions and PEP data (free, no auth required)
21
+ *
22
+ * Tools:
23
+ * - search_entities: search sanctioned entities by name, schema, or country
24
+ * - get_entity: get full details for a specific entity by ID
25
+ */
26
+
27
+
28
+ const BASE = 'https://api.opensanctions.org';
29
+
30
+ // ── Types ─────────────────────────────────────────────────────────────
31
+
32
+ type OSEntity = {
33
+ id?: string | null;
34
+ caption?: string | null;
35
+ schema?: string | null;
36
+ properties?: Record<string, string[]> | null;
37
+ datasets?: string[] | null;
38
+ referents?: string[] | null;
39
+ first_seen?: string | null;
40
+ last_seen?: string | null;
41
+ last_change?: string | null;
42
+ target?: boolean | null;
43
+ score?: number | null;
44
+ features?: Record<string, number> | null;
45
+ };
46
+
47
+ type OSSearchResponse = {
48
+ total?: { value?: number; relation?: string } | null;
49
+ results: OSEntity[];
50
+ };
51
+
52
+ function formatEntity(e: OSEntity) {
53
+ const props = e.properties ?? {};
54
+ return {
55
+ id: e.id ?? null,
56
+ caption: e.caption ?? null,
57
+ schema: e.schema ?? null,
58
+ datasets: e.datasets ?? [],
59
+ target: e.target ?? null,
60
+ score: e.score ?? null,
61
+ first_seen: e.first_seen ?? null,
62
+ last_seen: e.last_seen ?? null,
63
+ last_change: e.last_change ?? null,
64
+ names: props.name ?? [],
65
+ countries: props.country ?? [],
66
+ birth_date: props.birthDate?.[0] ?? null,
67
+ nationality: props.nationality ?? [],
68
+ topics: props.topics ?? [],
69
+ position: props.position?.[0] ?? null,
70
+ notes: props.notes ?? [],
71
+ };
72
+ }
73
+
74
+ // ── Tool definitions ──────────────────────────────────────────────────
75
+
76
+ const tools: McpToolExport['tools'] = [
77
+ {
78
+ name: 'search_entities',
79
+ description:
80
+ 'Search global sanctions, watchlists, and PEP (politically exposed persons) databases. Returns matched entities with names, countries, datasets, and sanctions details. Example: search_entities("Vladimir Putin") or search_entities("Huawei", schema="Company")',
81
+ inputSchema: {
82
+ type: 'object',
83
+ properties: {
84
+ query: { type: 'string', description: 'Name or keyword to search (e.g., "Gazprom", "Kim Jong")' },
85
+ schema: { type: 'string', description: 'Entity type: "Person", "Company", "Organization", "Vessel", "Aircraft"' },
86
+ countries: { type: 'string', description: 'Comma-separated country codes (e.g., "ru,cn,ir")' },
87
+ },
88
+ required: ['query'],
89
+ },
90
+ },
91
+ {
92
+ name: 'get_entity',
93
+ description:
94
+ 'Get full details for a sanctioned entity by its OpenSanctions ID. Returns all properties including names, addresses, identifiers, sanctions programs, and related entities.',
95
+ inputSchema: {
96
+ type: 'object',
97
+ properties: {
98
+ id: { type: 'string', description: 'OpenSanctions entity ID (e.g., "Q7747")' },
99
+ },
100
+ required: ['id'],
101
+ },
102
+ },
103
+ ];
104
+
105
+ // ── callTool dispatcher ───────────────────────────────────────────────
106
+
107
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
108
+ switch (name) {
109
+ case 'search_entities':
110
+ return searchEntities(
111
+ args.query as string,
112
+ args.schema as string | undefined,
113
+ args.countries as string | undefined,
114
+ );
115
+ case 'get_entity':
116
+ return getEntity(args.id as string);
117
+ default:
118
+ throw new Error(`Unknown tool: ${name}`);
119
+ }
120
+ }
121
+
122
+ // ── Tool implementations ─────────────────────────────────────────────
123
+
124
+ async function searchEntities(query: string, schema?: string, countries?: string) {
125
+ const params = new URLSearchParams({ q: query, limit: '20' });
126
+ if (schema) params.set('schema', schema);
127
+ if (countries) {
128
+ for (const c of countries.split(',')) {
129
+ params.append('countries', c.trim());
130
+ }
131
+ }
132
+
133
+ const res = await fetch(`${BASE}/search/default?${params}`, {
134
+ headers: { Accept: 'application/json' },
135
+ });
136
+ if (!res.ok) {
137
+ const text = await res.text();
138
+ throw new Error(`OpenSanctions API error (${res.status}): ${text}`);
139
+ }
140
+
141
+ const data = (await res.json()) as OSSearchResponse;
142
+
143
+ return {
144
+ query,
145
+ total: data.total?.value ?? data.results.length,
146
+ returned: data.results.length,
147
+ entities: data.results.map(formatEntity),
148
+ };
149
+ }
150
+
151
+ async function getEntity(id: string) {
152
+ const res = await fetch(`${BASE}/entities/${id}`, {
153
+ headers: { Accept: 'application/json' },
154
+ });
155
+ if (!res.ok) throw new Error(`OpenSanctions API error (${res.status}): entity ${id} not found`);
156
+
157
+ const data = (await res.json()) as OSEntity;
158
+ return formatEntity(data);
159
+ }
160
+
161
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }