@pipeworx/mcp-openaire 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,61 @@
1
+ # mcp-openaire
2
+
3
+ OpenAIRE MCP — EU research outputs (publications, datasets, software, projects)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `search_publications` | Search scholarly publications (articles, preprints, theses, books). |
12
+ | `search_datasets` | Search research datasets. |
13
+ | `search_software` | Search research software registrations. |
14
+ | `search_projects` | Search funded research projects (CORDIS for EC; also NSF, NIH, etc.). |
15
+ | `get_research_product` | Fetch a single research product (publication / dataset / software) by OpenAIRE id. |
16
+ | `get_project` | Fetch a project by OpenAIRE id. |
17
+
18
+ ## Quick Start
19
+
20
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "openaire": {
26
+ "url": "https://gateway.pipeworx.io/openaire/mcp"
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "pipeworx": {
38
+ "url": "https://gateway.pipeworx.io/mcp"
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## Using with ask_pipeworx
45
+
46
+ Instead of calling tools directly, you can ask questions in plain English:
47
+
48
+ ```
49
+ ask_pipeworx({ question: "your question about Openaire data" })
50
+ ```
51
+
52
+ The gateway picks the right tool and fills the arguments automatically.
53
+
54
+ ## More
55
+
56
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
57
+ - [pipeworx.io](https://pipeworx.io)
58
+
59
+ ## License
60
+
61
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-openaire",
3
+ "version": "0.1.0",
4
+ "description": "OpenAIRE MCP — EU research outputs (publications, datasets, software, projects)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "openaire"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-openaire"
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/openaire",
4
+ "title": "Openaire",
5
+ "description": "OpenAIRE MCP — EU research outputs (publications, datasets, software, projects)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/openaire",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-openaire",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/openaire/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,199 @@
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
+ * OpenAIRE MCP — EU research outputs (publications, datasets, software, projects)
21
+ *
22
+ * Graph API v1 — research outputs live under `/researchProducts` with a `type`
23
+ * filter; projects under `/projects`. Single-entity fetch uses the same paths
24
+ * with `?id=…` query (the API is filter-based, not REST-style by-id paths).
25
+ *
26
+ * API docs: https://graph.openaire.eu/docs/apis/graph-api/
27
+ * Auth: none.
28
+ */
29
+
30
+
31
+ const BASE = 'https://api.openaire.eu/graph/v1';
32
+
33
+ const COMMON_SEARCH_PROPS = {
34
+ query: { type: 'string', description: 'Free-text query (matches title/abstract/keywords)' },
35
+ size: { type: 'number', description: 'Page size, 1-100 (default 20)' },
36
+ page: { type: 'number', description: '1-based page (default 1)' },
37
+ } as const;
38
+
39
+ const tools: McpToolExport['tools'] = [
40
+ {
41
+ name: 'search_publications',
42
+ description: 'Search scholarly publications (articles, preprints, theses, books).',
43
+ inputSchema: {
44
+ type: 'object',
45
+ properties: {
46
+ ...COMMON_SEARCH_PROPS,
47
+ funder: { type: 'string', description: 'Funder short name — e.g. "EC", "NIH", "NSF", "WT"' },
48
+ country: { type: 'string', description: 'Country code — ISO 3166-1 alpha-2' },
49
+ from_year: { type: 'string', description: 'Earliest publication year (YYYY)' },
50
+ to_year: { type: 'string', description: 'Latest publication year (YYYY)' },
51
+ open_access: { type: 'boolean', description: 'Restrict to open-access publications' },
52
+ },
53
+ required: ['query'],
54
+ },
55
+ },
56
+ {
57
+ name: 'search_datasets',
58
+ description: 'Search research datasets.',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ ...COMMON_SEARCH_PROPS,
63
+ from_year: { type: 'string' },
64
+ to_year: { type: 'string' },
65
+ },
66
+ required: ['query'],
67
+ },
68
+ },
69
+ {
70
+ name: 'search_software',
71
+ description: 'Search research software registrations.',
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: { ...COMMON_SEARCH_PROPS },
75
+ required: ['query'],
76
+ },
77
+ },
78
+ {
79
+ name: 'search_projects',
80
+ description: 'Search funded research projects (CORDIS for EC; also NSF, NIH, etc.).',
81
+ inputSchema: {
82
+ type: 'object',
83
+ properties: {
84
+ ...COMMON_SEARCH_PROPS,
85
+ funder: { type: 'string', description: 'Funder short name' },
86
+ country: { type: 'string', description: 'Coordinator country (ISO alpha-2)' },
87
+ from_year: { type: 'string', description: 'Earliest project start year' },
88
+ },
89
+ required: ['query'],
90
+ },
91
+ },
92
+ {
93
+ name: 'get_research_product',
94
+ description: 'Fetch a single research product (publication / dataset / software) by OpenAIRE id.',
95
+ inputSchema: {
96
+ type: 'object',
97
+ properties: { id: { type: 'string', description: 'OpenAIRE id (e.g. "doi_dedup___::abc...")' } },
98
+ required: ['id'],
99
+ },
100
+ },
101
+ {
102
+ name: 'get_project',
103
+ description: 'Fetch a project by OpenAIRE id.',
104
+ inputSchema: {
105
+ type: 'object',
106
+ properties: { id: { type: 'string', description: 'OpenAIRE id' } },
107
+ required: ['id'],
108
+ },
109
+ },
110
+ ];
111
+
112
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
113
+ switch (name) {
114
+ case 'search_publications':
115
+ return searchProducts('publication', args);
116
+ case 'search_datasets':
117
+ return searchProducts('dataset', args);
118
+ case 'search_software':
119
+ return searchProducts('software', args);
120
+ case 'search_projects':
121
+ return searchProjects(args);
122
+ case 'get_research_product':
123
+ return fetchById('researchProducts', reqStr(args, 'id', '"doi_dedup___::abc..."'));
124
+ case 'get_project':
125
+ return fetchById('projects', reqStr(args, 'id', '"corda__h2020::..."'));
126
+ default:
127
+ throw new Error(`Unknown tool: ${name}`);
128
+ }
129
+ }
130
+
131
+ async function searchProducts(type: string, args: Record<string, unknown>) {
132
+ const params = new URLSearchParams({
133
+ search: String(args.query),
134
+ type,
135
+ pageSize: String(Math.min(100, Math.max(1, (args.size as number) ?? 20))),
136
+ page: String(Math.max(1, (args.page as number) ?? 1)),
137
+ });
138
+ if (args.funder) params.set('relFundingShortName', String(args.funder));
139
+ if (args.country) params.set('country', String(args.country));
140
+ if (args.from_year) params.set('fromPublicationDate', `${args.from_year}-01-01`);
141
+ if (args.to_year) params.set('toPublicationDate', `${args.to_year}-12-31`);
142
+ if (args.open_access === true) params.set('bestOpenAccessRouteImpl', 'gold');
143
+ return openaireFetch('researchProducts', params, args.query as string);
144
+ }
145
+
146
+ async function searchProjects(args: Record<string, unknown>) {
147
+ const params = new URLSearchParams({
148
+ search: String(args.query),
149
+ pageSize: String(Math.min(100, Math.max(1, (args.size as number) ?? 20))),
150
+ page: String(Math.max(1, (args.page as number) ?? 1)),
151
+ });
152
+ // /projects uses `fundingShortName` (no `rel` prefix) and `relOrganizationCountryCode`
153
+ if (args.funder) params.set('fundingShortName', String(args.funder));
154
+ if (args.country) params.set('relOrganizationCountryCode', String(args.country));
155
+ if (args.from_year) params.set('fromStartDate', `${args.from_year}-01-01`);
156
+ return openaireFetch('projects', params, args.query as string);
157
+ }
158
+
159
+ async function openaireFetch(kind: string, params: URLSearchParams, q: string) {
160
+ const url = `${BASE}/${kind}?${params}`;
161
+ const res = await fetch(url, { headers: { Accept: 'application/json' } });
162
+ if (!res.ok) {
163
+ const body = await res.text();
164
+ throw new Error(`OpenAIRE error: ${res.status} ${body.slice(0, 200)}`);
165
+ }
166
+ const data = (await res.json()) as { header?: { numFound?: number; pageSize?: number; page?: number }; results?: unknown[] };
167
+ return {
168
+ query: q,
169
+ total: data.header?.numFound ?? null,
170
+ page: data.header?.page ?? null,
171
+ page_size: data.header?.pageSize ?? null,
172
+ count: data.results?.length ?? 0,
173
+ results: data.results ?? [],
174
+ };
175
+ }
176
+
177
+ async function fetchById(kind: string, id: string) {
178
+ const params = new URLSearchParams({ id });
179
+ const url = `${BASE}/${kind}?${params}`;
180
+ const res = await fetch(url, { headers: { Accept: 'application/json' } });
181
+ if (!res.ok) {
182
+ const body = await res.text();
183
+ throw new Error(`OpenAIRE error: ${res.status} ${body.slice(0, 200)}`);
184
+ }
185
+ const data = (await res.json()) as { results?: unknown[] };
186
+ const first = data.results?.[0];
187
+ if (!first) throw new Error(`OpenAIRE: ${kind} ${id} not found`);
188
+ return first;
189
+ }
190
+
191
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
192
+ const v = args[key];
193
+ if (typeof v !== 'string' || !v.trim()) {
194
+ throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
195
+ }
196
+ return v;
197
+ }
198
+
199
+ 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
+ }