@pipeworx/mcp-newsdata 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 +21 -0
- package/README.md +55 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +233 -0
- package/tsconfig.json +14 -0
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-newsdata
|
|
2
|
+
|
|
3
|
+
NewsData.io MCP — wraps the NewsData.io global news API (newsdata.io)
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 744+ 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
|
+
"newsdata": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/newsdata/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 744+ 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 Newsdata 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-newsdata",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NewsData.io MCP — wraps the NewsData.io global news API (newsdata.io)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "newsdata"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-newsdata"
|
|
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/newsdata",
|
|
4
|
+
"title": "Newsdata",
|
|
5
|
+
"description": "NewsData.io MCP — wraps the NewsData.io global news API (newsdata.io)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/newsdata",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-newsdata",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/newsdata/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
* NewsData.io MCP — wraps the NewsData.io global news API (newsdata.io)
|
|
21
|
+
*
|
|
22
|
+
* Tools:
|
|
23
|
+
* - latest_news: latest global news headlines/articles, filterable by query,
|
|
24
|
+
* country, category, and language
|
|
25
|
+
* - crypto_news: latest cryptocurrency news headlines/articles
|
|
26
|
+
* - news_sources: list available news sources by country/category/language
|
|
27
|
+
*
|
|
28
|
+
* Dual-key model: _apiKey is OPTIONAL. Pass your own NewsData.io key for
|
|
29
|
+
* higher limits, or omit it to use the shared Pipeworx key (injected by the
|
|
30
|
+
* gateway). Key is passed as the `apikey` query param.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const BASE_URL = 'https://newsdata.io/api/1';
|
|
35
|
+
|
|
36
|
+
const tools: McpToolExport['tools'] = [
|
|
37
|
+
{
|
|
38
|
+
name: 'latest_news',
|
|
39
|
+
description:
|
|
40
|
+
'Get the latest global news headlines and articles. Filter by keyword, country (2-letter, e.g. "us"), category (business, technology, politics, sports, health, science), and language. Returns article title, description, link, source, publish date, category, and country. Paginate via the nextPage token. Example: latest_news({ query: "election", country: "us", category: "politics" })',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object' as const,
|
|
43
|
+
properties: {
|
|
44
|
+
query: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Keyword or phrase to search news articles for, e.g. "election", "AI chips"',
|
|
47
|
+
},
|
|
48
|
+
country: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: '2-letter country code to filter news by, e.g. "us", "gb", "in"',
|
|
51
|
+
},
|
|
52
|
+
category: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'News category, e.g. "business", "technology", "politics", "sports", "health", "science"',
|
|
55
|
+
},
|
|
56
|
+
language: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Language code to filter news by, e.g. "en", "es", "fr"',
|
|
59
|
+
},
|
|
60
|
+
page: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'nextPage token returned from a prior call, to fetch the next page of results',
|
|
63
|
+
},
|
|
64
|
+
_apiKey: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Optional — your own NewsData.io API key for higher limits; omit to use the shared Pipeworx key.',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'crypto_news',
|
|
73
|
+
description:
|
|
74
|
+
'Get the latest cryptocurrency news headlines and articles. Filter by keyword, coin ticker(s) (e.g. "btc,eth"), and language. Returns article title, description, link, source, publish date, category, and country. Example: crypto_news({ coin: "btc,eth", query: "etf" })',
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: 'object' as const,
|
|
77
|
+
properties: {
|
|
78
|
+
query: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'Keyword or phrase to search crypto news for, e.g. "etf", "halving"',
|
|
81
|
+
},
|
|
82
|
+
coin: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Comma-separated coin ticker(s) to filter by, e.g. "btc,eth"',
|
|
85
|
+
},
|
|
86
|
+
language: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
description: 'Language code to filter news by, e.g. "en", "es", "fr"',
|
|
89
|
+
},
|
|
90
|
+
_apiKey: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
description: 'Optional — your own NewsData.io API key for higher limits; omit to use the shared Pipeworx key.',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'news_sources',
|
|
99
|
+
description:
|
|
100
|
+
'List available global news sources. Filter by country (2-letter), category, and language. Returns source id, name, url, category, country, and language — useful for discovering which outlets cover a given region or topic. Example: news_sources({ country: "us", category: "technology" })',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object' as const,
|
|
103
|
+
properties: {
|
|
104
|
+
country: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: '2-letter country code to filter sources by, e.g. "us", "gb"',
|
|
107
|
+
},
|
|
108
|
+
category: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'News category to filter sources by, e.g. "business", "technology"',
|
|
111
|
+
},
|
|
112
|
+
language: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
description: 'Language code to filter sources by, e.g. "en", "es"',
|
|
115
|
+
},
|
|
116
|
+
_apiKey: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: 'Optional — your own NewsData.io API key for higher limits; omit to use the shared Pipeworx key.',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
interface NewsArticle {
|
|
126
|
+
title?: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
link?: string;
|
|
129
|
+
source_id?: string;
|
|
130
|
+
pubDate?: string;
|
|
131
|
+
category?: string[] | string;
|
|
132
|
+
country?: string[] | string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface NewsListResponse {
|
|
136
|
+
status?: string;
|
|
137
|
+
totalResults?: number;
|
|
138
|
+
results?: NewsArticle[];
|
|
139
|
+
nextPage?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface NewsSource {
|
|
143
|
+
id?: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
url?: string;
|
|
146
|
+
category?: string[] | string;
|
|
147
|
+
country?: string[] | string;
|
|
148
|
+
language?: string[] | string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface SourcesResponse {
|
|
152
|
+
results?: NewsSource[];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function newsdataGet(apiKey: string, path: string, params: URLSearchParams): Promise<unknown> {
|
|
156
|
+
params.set('apikey', apiKey);
|
|
157
|
+
const res = await fetch(`${BASE_URL}${path}?${params}`);
|
|
158
|
+
if (!res.ok) {
|
|
159
|
+
const text = await res.text();
|
|
160
|
+
return { error: res.status, message: text };
|
|
161
|
+
}
|
|
162
|
+
return res.json();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function mapArticles(data: NewsListResponse) {
|
|
166
|
+
const results = data.results ?? [];
|
|
167
|
+
return {
|
|
168
|
+
totalResults: data.totalResults,
|
|
169
|
+
nextPage: data.nextPage,
|
|
170
|
+
articles: results.map((a) => ({
|
|
171
|
+
title: a.title,
|
|
172
|
+
description: a.description,
|
|
173
|
+
link: a.link,
|
|
174
|
+
source: a.source_id,
|
|
175
|
+
pubDate: a.pubDate,
|
|
176
|
+
category: a.category,
|
|
177
|
+
country: a.country,
|
|
178
|
+
})),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
183
|
+
const apiKey = args._apiKey as string;
|
|
184
|
+
delete args._apiKey;
|
|
185
|
+
|
|
186
|
+
if (!apiKey) {
|
|
187
|
+
return { error: 'api_key_required', message: 'No NewsData.io key available.' };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
switch (name) {
|
|
191
|
+
case 'latest_news': {
|
|
192
|
+
const params = new URLSearchParams();
|
|
193
|
+
if (args.query) params.set('q', args.query as string);
|
|
194
|
+
if (args.country) params.set('country', args.country as string);
|
|
195
|
+
if (args.category) params.set('category', args.category as string);
|
|
196
|
+
if (args.language) params.set('language', args.language as string);
|
|
197
|
+
if (args.page) params.set('page', args.page as string);
|
|
198
|
+
const data = await newsdataGet(apiKey, '/latest', params);
|
|
199
|
+
if (data && typeof data === 'object' && 'error' in (data as object)) return data;
|
|
200
|
+
return mapArticles(data as NewsListResponse);
|
|
201
|
+
}
|
|
202
|
+
case 'crypto_news': {
|
|
203
|
+
const params = new URLSearchParams();
|
|
204
|
+
if (args.query) params.set('q', args.query as string);
|
|
205
|
+
if (args.coin) params.set('coin', args.coin as string);
|
|
206
|
+
if (args.language) params.set('language', args.language as string);
|
|
207
|
+
const data = await newsdataGet(apiKey, '/crypto', params);
|
|
208
|
+
if (data && typeof data === 'object' && 'error' in (data as object)) return data;
|
|
209
|
+
return mapArticles(data as NewsListResponse);
|
|
210
|
+
}
|
|
211
|
+
case 'news_sources': {
|
|
212
|
+
const params = new URLSearchParams();
|
|
213
|
+
if (args.country) params.set('country', args.country as string);
|
|
214
|
+
if (args.category) params.set('category', args.category as string);
|
|
215
|
+
if (args.language) params.set('language', args.language as string);
|
|
216
|
+
const data = await newsdataGet(apiKey, '/sources', params);
|
|
217
|
+
if (data && typeof data === 'object' && 'error' in (data as object)) return data;
|
|
218
|
+
const sources = (data as SourcesResponse).results ?? [];
|
|
219
|
+
return sources.map((s) => ({
|
|
220
|
+
id: s.id,
|
|
221
|
+
name: s.name,
|
|
222
|
+
url: s.url,
|
|
223
|
+
category: s.category,
|
|
224
|
+
country: s.country,
|
|
225
|
+
language: s.language,
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
default:
|
|
229
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
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
|
+
}
|