@pipeworx/mcp-lens-org 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,57 @@
1
+ # mcp-lens-org
2
+
3
+ Lens.org patent + scholarly search (free academic key required)
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
+ | `patents_search` | Patent search. |
12
+ | `scholarly_search` | Scholarly works search. |
13
+
14
+ ## Quick Start
15
+
16
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "lens-org": {
22
+ "url": "https://gateway.pipeworx.io/lens-org/mcp"
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ Or connect to the full Pipeworx gateway for access to all 250+ data sources:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "pipeworx": {
34
+ "url": "https://gateway.pipeworx.io/mcp"
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Using with ask_pipeworx
41
+
42
+ Instead of calling tools directly, you can ask questions in plain English:
43
+
44
+ ```
45
+ ask_pipeworx({ question: "your question about Lens Org data" })
46
+ ```
47
+
48
+ The gateway picks the right tool and fills the arguments automatically.
49
+
50
+ ## More
51
+
52
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
53
+ - [pipeworx.io](https://pipeworx.io)
54
+
55
+ ## License
56
+
57
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-lens-org",
3
+ "version": "0.1.0",
4
+ "description": "Lens.org patent + scholarly search (free academic key required)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "lens-org"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-lens-org"
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/lens-org",
4
+ "title": "Lens Org",
5
+ "description": "Lens.org patent + scholarly search (free academic key required)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/lens-org",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-lens-org",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/lens-org/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,109 @@
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
+ * Lens.org MCP — patent + scholarly platform.
21
+ *
22
+ * Auth: Lens Bearer token. Platform: PLATFORM_LENS_KEY. BYO: ?_apiKey=…
23
+ */
24
+
25
+
26
+ const BASE = 'https://api.lens.org';
27
+ const UA = 'pipeworx-mcp-lens-org/1.0 (+https://pipeworx.io)';
28
+
29
+ const tools: McpToolExport['tools'] = [
30
+ {
31
+ name: 'patents_search',
32
+ description: 'Patent search.',
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {
36
+ query: { type: 'string', description: 'Free-text or Lucene-style query.' },
37
+ size: { type: 'number', description: '1-1000 (default 25).' },
38
+ from: { type: 'number' },
39
+ },
40
+ required: ['query'],
41
+ },
42
+ },
43
+ {
44
+ name: 'scholarly_search',
45
+ description: 'Scholarly works search.',
46
+ inputSchema: {
47
+ type: 'object',
48
+ properties: {
49
+ query: { type: 'string' },
50
+ size: { type: 'number' },
51
+ from: { type: 'number' },
52
+ },
53
+ required: ['query'],
54
+ },
55
+ },
56
+ { name: 'patent', description: 'Single patent by lens_id.', inputSchema: { type: 'object', properties: { lens_id: { type: 'string' } }, required: ['lens_id'] } },
57
+ { name: 'scholarly', description: 'Single scholarly work.', inputSchema: { type: 'object', properties: { lens_id: { type: 'string' } }, required: ['lens_id'] } },
58
+ ];
59
+
60
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
61
+ const apiKey = (args._apiKey as string | undefined)?.trim();
62
+ if (!apiKey) throw new Error('Lens.org requires a Bearer token. Get one free for academic use at https://www.lens.org/lens/user/subscriptions and pass via PLATFORM_LENS_KEY or ?_apiKey=…');
63
+ const body = (extra: Record<string, unknown>) => ({
64
+ query: { match: { 'title': reqStr(args, 'query', '"machine learning"') } },
65
+ size: Math.min(1000, Math.max(1, (args.size as number) ?? 25)),
66
+ from: Math.max(0, (args.from as number) ?? 0),
67
+ ...extra,
68
+ });
69
+ switch (name) {
70
+ case 'patents_search':
71
+ return lensPost(apiKey, '/patent/search', body({}));
72
+ case 'scholarly_search':
73
+ return lensPost(apiKey, '/scholarly/search', body({}));
74
+ case 'patent':
75
+ return lensGet(apiKey, `/patent/${encodeURIComponent(reqStr(args, 'lens_id', '"<id>"'))}`);
76
+ case 'scholarly':
77
+ return lensGet(apiKey, `/scholarly/${encodeURIComponent(reqStr(args, 'lens_id', '"<id>"'))}`);
78
+ default:
79
+ throw new Error(`Unknown tool: ${name}`);
80
+ }
81
+ }
82
+
83
+ async function lensGet(apiKey: string, path: string): Promise<unknown> {
84
+ const res = await fetch(`${BASE}${path}`, {
85
+ headers: { Accept: 'application/json', 'User-Agent': UA, Authorization: `Bearer ${apiKey}` },
86
+ });
87
+ if (res.status === 401) throw new Error('Lens.org: 401 — invalid or expired token.');
88
+ if (!res.ok) throw new Error(`Lens.org: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
89
+ return res.json();
90
+ }
91
+
92
+ async function lensPost(apiKey: string, path: string, body: unknown): Promise<unknown> {
93
+ const res = await fetch(`${BASE}${path}`, {
94
+ method: 'POST',
95
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': UA, Authorization: `Bearer ${apiKey}` },
96
+ body: JSON.stringify(body),
97
+ });
98
+ if (res.status === 401) throw new Error('Lens.org: 401 — invalid or expired token.');
99
+ if (!res.ok) throw new Error(`Lens.org: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
100
+ return res.json();
101
+ }
102
+
103
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
104
+ const v = args[key];
105
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
106
+ return v;
107
+ }
108
+
109
+ 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
+ }