cleanfetch-mcp 0.0.0-stage → 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 CleanFetch
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 CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # CleanFetch MCP
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local **stdio** MCP server for [CleanFetch](https://cleanfetch.dev). It connects to the hosted CleanFetch MCP server at `https://api.cleanfetch.dev/mcp` with your API key, so every client sees the live catalog and charges credits on the same balance as REST.
4
+
5
+ - One JSON envelope for public pages, media, repositories, search and trends.
6
+ - Four context-saving tools: `cleanfetch_search_endpoints`, `cleanfetch_call`, `cleanfetch_ask`, `cleanfetch_balance`.
7
+ - Discovery works without a key; a key is only needed when a tool spends credits.
8
+ - Cache hits cost 0 credits. Verified `not_found` responses are billed once; 5xx and unconnected mapped routes cost 0.
9
+
10
+ ## Quick start
11
+
12
+ 1. Create a free key at <https://cleanfetch.dev/settings/apikeys> (30 credits on a first OAuth signup).
13
+ 2. Add the server to your client with the snippets below.
14
+ 3. Ask your agent: *"Search CleanFetch for a Hacker News endpoint and fetch the top stories."*
15
+
16
+ ### One-click install
17
+
18
+ - Cursor: [Install in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=cleanfetch&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsZWFuZmV0Y2gtbWNwIl0sImVudiI6eyJDTEVBTkZFVENIX0FQSV9LRVkiOiJZT1VSX0tFWSJ9fQ==) — replace `YOUR_KEY` after install.
19
+ - VS Code: [Install in VS Code](vscode:mcp/install?%7B%22name%22%3A%22cleanfetch%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cleanfetch-mcp%22%5D%2C%22env%22%3A%7B%22CLEANFETCH_API_KEY%22%3A%22%24%7Binput%3Acleanfetch-key%7D%22%7D%7D) — VS Code asks for the key once.
20
+
21
+ ### Claude Code
22
+
23
+ ```bash
24
+ claude mcp add cleanfetch --env CLEANFETCH_API_KEY=cf_live_your_key -- npx -y cleanfetch-mcp
25
+ ```
26
+
27
+ ### Cursor, Windsurf, Claude Desktop
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "cleanfetch": {
33
+ "command": "npx",
34
+ "args": ["-y", "cleanfetch-mcp"],
35
+ "env": {
36
+ "CLEANFETCH_API_KEY": "cf_live_your_key"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### Codex
44
+
45
+ ```toml
46
+ [mcp_servers.cleanfetch]
47
+ command = "npx"
48
+ args = ["-y", "cleanfetch-mcp"]
49
+ env = { CLEANFETCH_API_KEY = "cf_live_your_key" }
50
+ ```
51
+
52
+ ## Remote HTTP instead
53
+
54
+ Any client that supports Streamable HTTP can skip this package:
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "cleanfetch": {
60
+ "type": "http",
61
+ "url": "https://api.cleanfetch.dev/mcp",
62
+ "headers": {
63
+ "x-api-key": "cf_live_your_key"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Flags
71
+
72
+ ```text
73
+ cleanfetch-mcp [--api-key cf_live_...] [--mcp-url https://api.cleanfetch.dev/mcp]
74
+ ```
75
+
76
+ | Flag | Environment | Default |
77
+ | --- | --- | --- |
78
+ | `--api-key` | `CLEANFETCH_API_KEY` | required for tool calls |
79
+ | `--mcp-url` | `CLEANFETCH_MCP_URL` | `https://api.cleanfetch.dev/mcp` |
80
+
81
+ `--api-key` exists for clients that pass an argument array and do not render an `env` field. Prefer the environment variable in shared configs so the key does not appear in process arguments.
82
+
83
+ ## Tools
84
+
85
+ | Tool | What it does | Credits |
86
+ | --- | --- | --- |
87
+ | `cleanfetch_search_endpoints` | Search 1,100+ catalog operations by keyword, platform or path | 0 |
88
+ | `cleanfetch_call` | Call any operation with path, query and body params | catalog price |
89
+ | `cleanfetch_ask` | Turn a plain-English question into matching endpoints | 0 |
90
+ | `cleanfetch_balance` | Read the key's credit balance and paid status | 0 |
91
+
92
+ ## Development
93
+
94
+ ```bash
95
+ npm install
96
+ npm run build
97
+ npm test
98
+ node dist/index.js --help
99
+ ```
100
+
101
+ ## License
102
+
103
+ MIT
package/dist/config.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Resolve the API key and hosted MCP URL from flags, environment and defaults.
3
+ *
4
+ * Flags win over the environment. `--api-key` is accepted because desktop MCP
5
+ * clients pass arguments as an array and do not always expose `env` in their
6
+ * one-click install links.
7
+ */
8
+ export const DEFAULT_MCP_URL = 'https://api.cleanfetch.dev/mcp';
9
+ export function parseArgs(argv) {
10
+ let apiKey = process.env.CLEANFETCH_API_KEY?.trim() ?? '';
11
+ let mcpUrl = process.env.CLEANFETCH_MCP_URL?.trim() || DEFAULT_MCP_URL;
12
+ let help = false;
13
+ for (let index = 0; index < argv.length; index += 1) {
14
+ const arg = argv[index];
15
+ if (arg === '--help' || arg === '-h') {
16
+ help = true;
17
+ continue;
18
+ }
19
+ if (arg === '--api-key') {
20
+ apiKey = argv[index + 1]?.trim() ?? '';
21
+ index += 1;
22
+ continue;
23
+ }
24
+ if (arg.startsWith('--api-key=')) {
25
+ apiKey = arg.slice('--api-key='.length).trim();
26
+ continue;
27
+ }
28
+ if (arg === '--mcp-url') {
29
+ mcpUrl = argv[index + 1]?.trim() || mcpUrl;
30
+ index += 1;
31
+ continue;
32
+ }
33
+ if (arg.startsWith('--mcp-url=')) {
34
+ mcpUrl = arg.slice('--mcp-url='.length).trim() || mcpUrl;
35
+ }
36
+ }
37
+ return { apiKey, mcpUrl, help };
38
+ }
39
+ export const KEY_HELP = 'Set CLEANFETCH_API_KEY (or pass --api-key) to a CleanFetch API key (cf_live_...). Create one free at https://cleanfetch.dev/settings/apikeys.';
package/dist/index.js ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CleanFetch MCP over stdio.
4
+ *
5
+ * Runs locally and speaks MCP on stdin/stdout. Tools come from the hosted
6
+ * CleanFetch MCP server, which this process calls with your CLEANFETCH_API_KEY
7
+ * as `x-api-key`. Tool lists and schemas therefore always match the hosted
8
+ * server and the REST API, and credits are charged to the key's account.
9
+ */
10
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
11
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
12
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
13
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
14
+ import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
15
+ import { KEY_HELP, parseArgs } from './config.js';
16
+ const VERSION = '0.1.0';
17
+ const config = parseArgs(process.argv.slice(2));
18
+ if (config.help) {
19
+ process.stderr.write([
20
+ 'cleanfetch-mcp — CleanFetch MCP server over stdio',
21
+ '',
22
+ 'Usage: cleanfetch-mcp [--api-key cf_live_...] [--mcp-url https://api.cleanfetch.dev/mcp]',
23
+ '',
24
+ `Environment: CLEANFETCH_API_KEY, CLEANFETCH_MCP_URL`,
25
+ KEY_HELP,
26
+ '',
27
+ ].join('\n'));
28
+ process.exit(0);
29
+ }
30
+ /** stdout carries the protocol, so every diagnostic goes to stderr. */
31
+ function log(message) {
32
+ process.stderr.write(`[cleanfetch-mcp] ${message}\n`);
33
+ }
34
+ function errorMessage(error) {
35
+ return error instanceof Error ? error.message : String(error);
36
+ }
37
+ let upstream;
38
+ let connecting;
39
+ /** Connect to the hosted server once; a failed attempt is retried next request. */
40
+ function getUpstream() {
41
+ if (upstream)
42
+ return Promise.resolve(upstream);
43
+ connecting ??= (async () => {
44
+ const client = new Client({
45
+ name: 'cleanfetch-mcp-stdio',
46
+ version: VERSION,
47
+ });
48
+ const transport = new StreamableHTTPClientTransport(new URL(config.mcpUrl), {
49
+ requestInit: {
50
+ headers: {
51
+ ...(config.apiKey ? { 'x-api-key': config.apiKey } : {}),
52
+ 'user-agent': `cleanfetch-mcp-stdio/${VERSION}`,
53
+ },
54
+ },
55
+ });
56
+ try {
57
+ await client.connect(transport);
58
+ }
59
+ catch (error) {
60
+ await client.close().catch(() => { });
61
+ throw new Error(`Could not connect to ${config.mcpUrl}: ${errorMessage(error)}`);
62
+ }
63
+ client.onclose = () => {
64
+ upstream = undefined;
65
+ };
66
+ upstream = client;
67
+ return client;
68
+ })().finally(() => {
69
+ connecting = undefined;
70
+ });
71
+ return connecting;
72
+ }
73
+ function toolError(text) {
74
+ return { isError: true, content: [{ type: 'text', text }] };
75
+ }
76
+ async function main() {
77
+ // Connect before answering initialize so the hosted instructions and
78
+ // capabilities reach the client. Without a key or network, start anyway and
79
+ // explain the problem on each request.
80
+ let first;
81
+ try {
82
+ first = await getUpstream();
83
+ }
84
+ catch (error) {
85
+ log(errorMessage(error));
86
+ }
87
+ if (!config.apiKey)
88
+ log(KEY_HELP);
89
+ const upstreamCaps = first?.getServerCapabilities() ?? {};
90
+ const capabilities = { tools: {} };
91
+ if (upstreamCaps.resources)
92
+ capabilities.resources = {};
93
+ if (upstreamCaps.prompts)
94
+ capabilities.prompts = {};
95
+ const server = new Server({ name: 'cleanfetch', title: 'CleanFetch', version: VERSION }, { capabilities, instructions: first?.getInstructions() });
96
+ server.setRequestHandler(ListToolsRequestSchema, async (request) => {
97
+ const client = await getUpstream();
98
+ return client.listTools(request.params);
99
+ });
100
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
101
+ let client;
102
+ try {
103
+ client = await getUpstream();
104
+ }
105
+ catch (error) {
106
+ return toolError(errorMessage(error));
107
+ }
108
+ try {
109
+ // Pass the hosted result through untouched: it is the same { data, meta }
110
+ // envelope as REST, and tool errors already arrive as isError results.
111
+ return (await client.callTool(request.params));
112
+ }
113
+ catch (error) {
114
+ return toolError(`CleanFetch request failed: ${errorMessage(error)}`);
115
+ }
116
+ });
117
+ if (capabilities.resources) {
118
+ server.setRequestHandler(ListResourcesRequestSchema, async (request) => (await getUpstream()).listResources(request.params));
119
+ server.setRequestHandler(ListResourceTemplatesRequestSchema, async (request) => (await getUpstream()).listResourceTemplates(request.params));
120
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => (await getUpstream()).readResource(request.params));
121
+ }
122
+ if (capabilities.prompts) {
123
+ server.setRequestHandler(ListPromptsRequestSchema, async (request) => (await getUpstream()).listPrompts(request.params));
124
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => (await getUpstream()).getPrompt(request.params));
125
+ }
126
+ const shutdown = async () => {
127
+ await server.close().catch(() => { });
128
+ await upstream?.close().catch(() => { });
129
+ process.exit(0);
130
+ };
131
+ process.on('SIGINT', shutdown);
132
+ process.on('SIGTERM', shutdown);
133
+ process.stdin.on('close', shutdown);
134
+ await server.connect(new StdioServerTransport());
135
+ log(`ready (upstream ${config.mcpUrl}${first ? '' : ', not connected yet'})`);
136
+ }
137
+ main().catch((error) => {
138
+ log(`fatal: ${errorMessage(error)}`);
139
+ process.exit(1);
140
+ });
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "cleanfetch-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "CleanFetch MCP server over stdio. Uses your CLEANFETCH_API_KEY to call the hosted CleanFetch tools.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "cleanfetch-mcp": "dist/index.js"
9
+ },
10
+ "main": "dist/index.js",
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "start": "node dist/index.js",
22
+ "test": "node --import tsx --test tests/*.test.ts",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/techreone/cleanfetch-mcp.git"
28
+ },
29
+ "homepage": "https://cleanfetch.dev/docs/mcp",
30
+ "keywords": [
31
+ "mcp",
32
+ "model-context-protocol",
33
+ "cleanfetch",
34
+ "public-data",
35
+ "api",
36
+ "web-scraping",
37
+ "trends",
38
+ "hackernews",
39
+ "github"
40
+ ],
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.32.2"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^22.0.0",
46
+ "tsx": "^4.23.0",
47
+ "typescript": "^5.9.0"
48
+ }
49
+ }