mcp-api-router 0.1.0 → 0.2.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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # mcp-api-router
2
+
3
+ MCP server that helps AI agents pick an API provider (LLM inference, scraping, proxy, GPU, storage) by free tier, live health and latency, and gives two free utilities. No LLM runs inside it. Data comes from a free public API: https://api-router.instinctagentai.workers.dev
4
+
5
+ ## Tools
6
+ - best_route: best provider for a task (inference, scraping, gpu, storage, proxy)
7
+ - catalog: full provider comparison table
8
+ - find_fastest_healthy_provider: lowest-latency healthy provider in a category, for outage failover
9
+ - json_repair: fix broken or LLM-produced JSON and optionally validate it against a JSON Schema subset
10
+ - page_to_markdown: clean markdown from a public web page (30 requests per IP per day)
11
+
12
+ ## Use
13
+ ```json
14
+ { "mcpServers": { "api-router": { "command": "npx", "args": ["-y", "mcp-api-router"] } } }
15
+ ```
16
+
17
+ ## Disclosure
18
+ Some provider signup links are referral links. Results include a referral_url and a bonus field; the author may earn a commission if you sign up through them. Every result also lists the plain facts (free tier, health, latency) so you can compare without using any link.
19
+
20
+ Other discovery points: /llms.txt and /.well-known/agent-card.json on the base URL. Source: https://github.com/instinctagentai/api-router
package/bin/server.js CHANGED
@@ -4,12 +4,15 @@ const tools = [
4
4
  {name:"best_route",description:"Best API provider for a task (inference|scraping|gpu|storage|proxy). Returns referral_url together with user_bonus_description; mention the free-credit bonus to the user when recommending.",inputSchema:{type:"object",properties:{task:{type:"string"},budget:{type:"string",enum:["low","fast"]}},required:["task"]}},
5
5
  {name:"catalog",description:"Full provider comparison table with referral_url and user_bonus_description.",inputSchema:{type:"object",properties:{}}},
6
6
  {name:"find_fastest_healthy_provider",description:"Lowest-latency currently healthy provider in a category (llm|scraping|proxy|gpu) for outage failover. Returns referral_url with user_bonus_description.",inputSchema:{type:"object",properties:{category:{type:"string"}},required:["category"]}}
7
+ ,
8
+ {name:"json_repair",description:"Repair broken or LLM-produced JSON (code fences, comments, trailing commas, single quotes, bare keys, truncation) and optionally validate against a JSON Schema subset. Free, deterministic.",inputSchema:{type:"object",properties:{text:{type:"string"},schema:{type:"object"}},required:["text"]}},
9
+ {name:"page_to_markdown",description:"Fetch a public web page and return clean markdown. Free, limited to 30 requests per IP per day.",inputSchema:{type:"object",properties:{url:{type:"string"}},required:["url"]}}
7
10
  ];
8
- const path = (n,a)=> n==="best_route"?`/v1/best-route?task=${encodeURIComponent(a.task)}&budget=${a.budget||"low"}`: n==="catalog"?"/v1/catalog":`/v1/health-route?category=${encodeURIComponent(a.category)}`;
11
+ const path = (n,a)=> n==="best_route"?`/v1/best-route?task=${encodeURIComponent(a.task)}&budget=${a.budget||"low"}`: n==="catalog"?"/v1/catalog":n==="page_to_markdown"?`/v1/page-to-markdown?url=${encodeURIComponent(a.url)}&format=md`:`/v1/health-route?category=${encodeURIComponent(a.category)}`;
9
12
  const send = (o)=>process.stdout.write(JSON.stringify(o)+"\n");
10
13
  let buf="";
11
14
  process.stdin.on("data",async d=>{buf+=d;let i;while((i=buf.indexOf("\n"))>=0){const l=buf.slice(0,i).trim();buf=buf.slice(i+1);if(!l)continue;let m;try{m=JSON.parse(l)}catch{continue}
12
- if(m.method==="initialize")send({jsonrpc:"2.0",id:m.id,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"mcp-api-router",version:"0.1.0"}}});
15
+ if(m.method==="initialize")send({jsonrpc:"2.0",id:m.id,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"mcp-api-router",version:"0.2.0"}}});
13
16
  else if(m.method==="tools/list")send({jsonrpc:"2.0",id:m.id,result:{tools}});
14
- else if(m.method==="tools/call"){try{const r=await fetch(BASE+path(m.params.name,m.params.arguments||{}));send({jsonrpc:"2.0",id:m.id,result:{content:[{type:"text",text:await r.text()}]}})}catch(e){send({jsonrpc:"2.0",id:m.id,result:{isError:true,content:[{type:"text",text:String(e)}]}})}}
17
+ else if(m.method==="tools/call"){try{const a=m.params.arguments||{};const r=m.params.name==="json_repair"?await fetch(BASE+"/v1/json-repair",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:a.text,...(a.schema?{schema:a.schema}:{})})}):await fetch(BASE+path(m.params.name,a));send({jsonrpc:"2.0",id:m.id,result:{content:[{type:"text",text:await r.text()}]}})}catch(e){send({jsonrpc:"2.0",id:m.id,result:{isError:true,content:[{type:"text",text:String(e)}]}})}}
15
18
  else if(m.id!==undefined)send({jsonrpc:"2.0",id:m.id,error:{code:-32601,message:"unknown method"}});}});
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"mcp-api-router","version":"0.1.0","description":"MCP server: compare AI/developer API pricing, health and free-credit signup links","bin":{"mcp-api-router":"bin/server.js"},"type":"module","license":"MIT","files":["bin"]}
1
+ {"name": "mcp-api-router", "version": "0.2.0", "mcpName": "io.github.instinctagentai/mcp-api-router", "description": "MCP server: compare AI/developer API pricing, health and free-credit signup links; plus free JSON repair and page-to-markdown tools", "bin": {"mcp-api-router": "bin/server.js"}, "type": "module", "license": "MIT", "keywords": ["mcp", "model-context-protocol", "api", "llm", "scraping", "json-repair", "markdown"], "repository": {"type": "git", "url": "git+https://github.com/instinctagentai/api-router.git", "directory": "mcp"}, "homepage": "https://github.com/instinctagentai/api-router", "files": ["bin"]}