@free-api-list/mcp-server 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 +21 -0
- package/README.md +77 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +39 -0
- package/dist/tools/common.d.ts +20 -0
- package/dist/tools/common.js +44 -0
- package/dist/tools/get-api.d.ts +12 -0
- package/dist/tools/get-api.js +17 -0
- package/dist/tools/list-apis.d.ts +20 -0
- package/dist/tools/list-apis.js +30 -0
- package/dist/tools/search-apis.d.ts +12 -0
- package/dist/tools/search-apis.js +23 -0
- package/dist/tools/suggest-apis.d.ts +14 -0
- package/dist/tools/suggest-apis.js +60 -0
- package/package.json +60 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Curtis Thomas
|
|
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,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @free-api-list/mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@free-api-list/mcp-server)
|
|
4
|
+
|
|
5
|
+
An MCP server that exposes the [free-api-list](https://github.com/Curtis-Thomas/free-api-list-with-react) catalog as four tools any MCP client (Claude Desktop, Claude Code, Cursor, etc.) can call.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Input | Output |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `list_apis` | `category?`, `difficulty?`, `auth_required?`, `tags?` | Array of API summaries |
|
|
12
|
+
| `search_apis` | `query`, `limit?` | Top matches scored by name/description/tag overlap |
|
|
13
|
+
| `get_api` | `id` | The full validated `ApiEntry` |
|
|
14
|
+
| `suggest_apis_for_task` | `task_description` | Up to 5 APIs with a one-line rationale each |
|
|
15
|
+
|
|
16
|
+
The server does **not** make HTTP calls to the cataloged APIs — that is the consuming agent's job. Full input and output details: [MCP tools reference](https://github.com/Curtis-Thomas/free-api-list-with-react/blob/main/docs/reference/mcp-tools.md).
|
|
17
|
+
|
|
18
|
+
## Install (stdio)
|
|
19
|
+
|
|
20
|
+
Requires Node.js 24 or later. Most MCP clients start the server for you with `npx`, which downloads the latest version on first use:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx -y @free-api-list/mcp-server
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The catalog data ships inside the package (through its dependency `@free-api-list/catalog`), so the server works offline once installed and never reads files from this repository. To pin a version or skip the `npx` download, install it globally and use the `free-api-list-mcp` command instead:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g @free-api-list/mcp-server
|
|
30
|
+
free-api-list-mcp # speaks MCP over stdio; logs go to stderr
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Claude Code
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
claude mcp add free-api-list -- npx -y @free-api-list/mcp-server
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or, to share it with everyone working in a project, add it to the project's `.mcp.json`:
|
|
40
|
+
|
|
41
|
+
```jsonc
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"free-api-list": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "@free-api-list/mcp-server"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Claude Desktop
|
|
53
|
+
|
|
54
|
+
Open the Claude Desktop config (Settings → Developer → Edit Config) and add the same `mcpServers` block.
|
|
55
|
+
|
|
56
|
+
### Cursor / Cline / other MCP clients
|
|
57
|
+
|
|
58
|
+
Use the same `command: "npx"`, `args: ["-y", "@free-api-list/mcp-server"]` pattern. With a global install, use `command: "free-api-list-mcp"` and no args.
|
|
59
|
+
|
|
60
|
+
## Running from source
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm --filter @free-api-list/mcp-server start
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This runs `src/index.ts` directly via `tsx`, reads the catalog from `packages/catalog/apis/`, and serves the tools over stdio.
|
|
67
|
+
|
|
68
|
+
To check the package as npm users get it, run the pack smoke test. It builds, `pnpm pack`s the server and the catalog, installs the tarballs with npm in a temp folder, and lists the tools over stdio:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm --filter @free-api-list/mcp-server smoke
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Releases are cut with Changesets. See [`DEPLOY.md`](https://github.com/Curtis-Thomas/free-api-list-with-react/blob/main/DEPLOY.md#npm-mcp-server).
|
|
75
|
+
|
|
76
|
+
## Remote HTTP endpoint
|
|
77
|
+
|
|
78
|
+
A skeleton Cloudflare Worker entry lives at `src/worker.ts` for the eventual `freeapilist.com/mcp` hosted endpoint. Full HTTP transport wiring is a follow-up.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { loadCatalog } from "@free-api-list/catalog/load";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { buildServer } from "./server.js";
|
|
6
|
+
// package.json sits one level above both src/ (dev) and dist/ (published).
|
|
7
|
+
function readPackageVersion() {
|
|
8
|
+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
9
|
+
return typeof pkg === "object" &&
|
|
10
|
+
pkg !== null &&
|
|
11
|
+
"version" in pkg &&
|
|
12
|
+
typeof pkg.version === "string"
|
|
13
|
+
? pkg.version
|
|
14
|
+
: "0.0.0";
|
|
15
|
+
}
|
|
16
|
+
async function main() {
|
|
17
|
+
const { apis } = loadCatalog();
|
|
18
|
+
const server = buildServer({ apis, serverVersion: readPackageVersion() });
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
console.error(`free-api-list-mcp: serving ${apis.length} APIs over stdio`);
|
|
22
|
+
}
|
|
23
|
+
main().catch((error) => {
|
|
24
|
+
console.error("free-api-list-mcp fatal:", error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
export interface BuildServerOptions {
|
|
4
|
+
apis: ApiEntry[];
|
|
5
|
+
serverName?: string;
|
|
6
|
+
serverVersion?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildServer({ apis, serverName, serverVersion, }: BuildServerOptions): McpServer;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { jsonContent } from "./tools/common.js";
|
|
3
|
+
import { ApiNotFoundError, getApi, getApiInputSchema } from "./tools/get-api.js";
|
|
4
|
+
import { listApis, listApisInputSchema } from "./tools/list-apis.js";
|
|
5
|
+
import { searchApis, searchApisInputSchema } from "./tools/search-apis.js";
|
|
6
|
+
import { suggestApis, suggestApisInputSchema } from "./tools/suggest-apis.js";
|
|
7
|
+
export function buildServer({ apis, serverName = "free-api-list", serverVersion = "0.1.0", }) {
|
|
8
|
+
const server = new McpServer({ name: serverName, version: serverVersion });
|
|
9
|
+
server.registerTool("list_apis", {
|
|
10
|
+
description: "List free APIs in the catalog. Filter by category, difficulty, auth requirement, or tags.",
|
|
11
|
+
inputSchema: listApisInputSchema,
|
|
12
|
+
}, async (input) => jsonContent(listApis(apis, input)));
|
|
13
|
+
server.registerTool("search_apis", {
|
|
14
|
+
description: "Search the catalog by free-text query. Returns the top matches scored against name, description, and tags.",
|
|
15
|
+
inputSchema: searchApisInputSchema,
|
|
16
|
+
}, async (input) => jsonContent(searchApis(apis, input)));
|
|
17
|
+
server.registerTool("get_api", {
|
|
18
|
+
description: "Return the full ApiEntry for a single API id.",
|
|
19
|
+
inputSchema: getApiInputSchema,
|
|
20
|
+
}, async (input) => {
|
|
21
|
+
try {
|
|
22
|
+
return jsonContent(getApi(apis, input));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error instanceof ApiNotFoundError) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: "text", text: error.message }],
|
|
28
|
+
isError: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
server.registerTool("suggest_apis_for_task", {
|
|
35
|
+
description: "Given a natural-language task description, suggest up to 5 catalog APIs with a one-line rationale per recommendation.",
|
|
36
|
+
inputSchema: suggestApisInputSchema,
|
|
37
|
+
}, async (input) => jsonContent(suggestApis(apis, input)));
|
|
38
|
+
return server;
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
export interface ApiSummary {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
category: string;
|
|
7
|
+
difficulty: ApiEntry["difficulty"];
|
|
8
|
+
authRequired: boolean;
|
|
9
|
+
tags: string[];
|
|
10
|
+
documentationUrl: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function summarize(api: ApiEntry): ApiSummary;
|
|
13
|
+
export declare function jsonContent<T>(value: T): {
|
|
14
|
+
content: {
|
|
15
|
+
type: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
export declare function tokenize(text: string): string[];
|
|
20
|
+
export declare function scoreMatch(query: string, api: ApiEntry): number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function summarize(api) {
|
|
2
|
+
return {
|
|
3
|
+
id: api.id,
|
|
4
|
+
name: api.name,
|
|
5
|
+
description: api.description,
|
|
6
|
+
category: api.category,
|
|
7
|
+
difficulty: api.difficulty,
|
|
8
|
+
authRequired: api.auth.required,
|
|
9
|
+
tags: api.tags,
|
|
10
|
+
documentationUrl: api.documentationUrl,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function jsonContent(value) {
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: JSON.stringify(value, null, 2),
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function tokenize(text) {
|
|
24
|
+
return text
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.split(/[^a-z0-9]+/)
|
|
27
|
+
.filter((t) => t.length >= 2);
|
|
28
|
+
}
|
|
29
|
+
export function scoreMatch(query, api) {
|
|
30
|
+
const tokens = tokenize(query);
|
|
31
|
+
if (tokens.length === 0)
|
|
32
|
+
return 0;
|
|
33
|
+
const haystack = [api.name, api.description, api.category, ...api.tags].join(" ").toLowerCase();
|
|
34
|
+
let score = 0;
|
|
35
|
+
for (const token of tokens) {
|
|
36
|
+
if (haystack.includes(token))
|
|
37
|
+
score += 1;
|
|
38
|
+
if (api.name.toLowerCase().includes(token))
|
|
39
|
+
score += 2;
|
|
40
|
+
if (api.tags.some((t) => t.toLowerCase() === token))
|
|
41
|
+
score += 2;
|
|
42
|
+
}
|
|
43
|
+
return score;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const getApiInputSchema: {
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
};
|
|
6
|
+
export type GetApiInput = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class ApiNotFoundError extends Error {
|
|
10
|
+
constructor(id: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function getApi(apis: ApiEntry[], input: GetApiInput): ApiEntry;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiEntrySchema } from "@free-api-list/catalog";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const getApiInputSchema = {
|
|
4
|
+
id: z.string().min(1).describe("Catalog id of the API (e.g. 'cat-facts-ninja')"),
|
|
5
|
+
};
|
|
6
|
+
export class ApiNotFoundError extends Error {
|
|
7
|
+
constructor(id) {
|
|
8
|
+
super(`No API in the catalog with id "${id}"`);
|
|
9
|
+
this.name = "ApiNotFoundError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function getApi(apis, input) {
|
|
13
|
+
const found = apis.find((a) => a.id === input.id);
|
|
14
|
+
if (!found)
|
|
15
|
+
throw new ApiNotFoundError(input.id);
|
|
16
|
+
return ApiEntrySchema.parse(found);
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type ApiSummary } from "./common.js";
|
|
4
|
+
export declare const listApisInputSchema: {
|
|
5
|
+
category: z.ZodOptional<z.ZodString>;
|
|
6
|
+
difficulty: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
advanced: "advanced";
|
|
8
|
+
beginner: "beginner";
|
|
9
|
+
intermediate: "intermediate";
|
|
10
|
+
}>>;
|
|
11
|
+
auth_required: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
};
|
|
14
|
+
export interface ListApisInput {
|
|
15
|
+
category?: string | undefined;
|
|
16
|
+
difficulty?: ApiEntry["difficulty"] | undefined;
|
|
17
|
+
auth_required?: boolean | undefined;
|
|
18
|
+
tags?: string[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function listApis(apis: ApiEntry[], input: ListApisInput): ApiSummary[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { summarize } from "./common.js";
|
|
3
|
+
export const listApisInputSchema = {
|
|
4
|
+
category: z.string().optional().describe("Filter by category id (e.g. 'animals')"),
|
|
5
|
+
difficulty: z
|
|
6
|
+
.enum(["beginner", "intermediate", "advanced"])
|
|
7
|
+
.optional()
|
|
8
|
+
.describe("Filter by difficulty"),
|
|
9
|
+
auth_required: z.boolean().optional().describe("Only return APIs where auth.required matches"),
|
|
10
|
+
tags: z.array(z.string()).optional().describe("Only return APIs that contain all listed tags"),
|
|
11
|
+
};
|
|
12
|
+
export function listApis(apis, input) {
|
|
13
|
+
return apis
|
|
14
|
+
.filter((api) => {
|
|
15
|
+
if (input.category && api.category !== input.category)
|
|
16
|
+
return false;
|
|
17
|
+
if (input.difficulty && api.difficulty !== input.difficulty)
|
|
18
|
+
return false;
|
|
19
|
+
if (input.auth_required !== undefined && api.auth.required !== input.auth_required)
|
|
20
|
+
return false;
|
|
21
|
+
if (input.tags && input.tags.length > 0) {
|
|
22
|
+
const have = new Set(api.tags);
|
|
23
|
+
for (const t of input.tags)
|
|
24
|
+
if (!have.has(t))
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
})
|
|
29
|
+
.map(summarize);
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type ApiSummary } from "./common.js";
|
|
4
|
+
export declare const searchApisInputSchema: {
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
};
|
|
8
|
+
export interface SearchApisInput {
|
|
9
|
+
query: string;
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function searchApis(apis: ApiEntry[], input: SearchApisInput): ApiSummary[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { scoreMatch, summarize } from "./common.js";
|
|
3
|
+
export const searchApisInputSchema = {
|
|
4
|
+
query: z
|
|
5
|
+
.string()
|
|
6
|
+
.min(1)
|
|
7
|
+
.describe("Free-text query matched against name, description, tags, category"),
|
|
8
|
+
limit: z
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(50)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Maximum matches to return (default 10)"),
|
|
15
|
+
};
|
|
16
|
+
export function searchApis(apis, input) {
|
|
17
|
+
const limit = input.limit ?? 10;
|
|
18
|
+
const scored = apis
|
|
19
|
+
.map((api) => ({ api, score: scoreMatch(input.query, api) }))
|
|
20
|
+
.filter((entry) => entry.score > 0)
|
|
21
|
+
.sort((a, b) => b.score - a.score);
|
|
22
|
+
return scored.slice(0, limit).map((entry) => summarize(entry.api));
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiEntry } from "@free-api-list/catalog";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type ApiSummary } from "./common.js";
|
|
4
|
+
export declare const suggestApisInputSchema: {
|
|
5
|
+
task_description: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
export type SuggestApisInput = {
|
|
8
|
+
task_description: string;
|
|
9
|
+
};
|
|
10
|
+
export interface SuggestApisResult {
|
|
11
|
+
api: ApiSummary;
|
|
12
|
+
rationale: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function suggestApis(apis: ApiEntry[], input: SuggestApisInput): SuggestApisResult[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { scoreMatch, summarize, tokenize } from "./common.js";
|
|
3
|
+
export const suggestApisInputSchema = {
|
|
4
|
+
task_description: z
|
|
5
|
+
.string()
|
|
6
|
+
.min(5)
|
|
7
|
+
.describe("Plain-English description of what the user is trying to do"),
|
|
8
|
+
};
|
|
9
|
+
const STOP_WORDS = new Set([
|
|
10
|
+
"the",
|
|
11
|
+
"and",
|
|
12
|
+
"for",
|
|
13
|
+
"with",
|
|
14
|
+
"that",
|
|
15
|
+
"this",
|
|
16
|
+
"want",
|
|
17
|
+
"need",
|
|
18
|
+
"build",
|
|
19
|
+
"make",
|
|
20
|
+
"create",
|
|
21
|
+
"use",
|
|
22
|
+
"using",
|
|
23
|
+
"find",
|
|
24
|
+
"show",
|
|
25
|
+
"list",
|
|
26
|
+
"get",
|
|
27
|
+
"data",
|
|
28
|
+
"api",
|
|
29
|
+
"apis",
|
|
30
|
+
]);
|
|
31
|
+
function keywords(task) {
|
|
32
|
+
return tokenize(task).filter((t) => !STOP_WORDS.has(t));
|
|
33
|
+
}
|
|
34
|
+
function rationaleFor(api, terms) {
|
|
35
|
+
const reasons = [];
|
|
36
|
+
for (const term of terms) {
|
|
37
|
+
if (api.name.toLowerCase().includes(term))
|
|
38
|
+
reasons.push(`name mentions "${term}"`);
|
|
39
|
+
else if (api.tags.some((t) => t.toLowerCase() === term))
|
|
40
|
+
reasons.push(`tagged "${term}"`);
|
|
41
|
+
else if (api.category.toLowerCase().includes(term))
|
|
42
|
+
reasons.push(`category is "${api.category}"`);
|
|
43
|
+
else if (api.description.toLowerCase().includes(term))
|
|
44
|
+
reasons.push(`description mentions "${term}"`);
|
|
45
|
+
}
|
|
46
|
+
if (reasons.length === 0) {
|
|
47
|
+
return `Listed under ${api.category}; may apply to this task.`;
|
|
48
|
+
}
|
|
49
|
+
return reasons.slice(0, 3).join("; ");
|
|
50
|
+
}
|
|
51
|
+
export function suggestApis(apis, input) {
|
|
52
|
+
const terms = keywords(input.task_description);
|
|
53
|
+
const query = terms.join(" ");
|
|
54
|
+
const ranked = apis
|
|
55
|
+
.map((api) => ({ api, score: scoreMatch(query, api) }))
|
|
56
|
+
.filter((entry) => entry.score > 0)
|
|
57
|
+
.sort((a, b) => b.score - a.score);
|
|
58
|
+
const top = ranked.slice(0, 5);
|
|
59
|
+
return top.map(({ api }) => ({ api: summarize(api), rationale: rationaleFor(api, terms) }));
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@free-api-list/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An MCP server that lets AI agents list, search and get suggestions from a catalog of free public APIs.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"mcp-server",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"claude",
|
|
10
|
+
"free-api",
|
|
11
|
+
"public-api",
|
|
12
|
+
"api-catalog"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/Curtis-Thomas/free-api-list-with-react/tree/main/packages/mcp-server#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Curtis-Thomas/free-api-list-with-react/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Curtis-Thomas/free-api-list-with-react.git",
|
|
21
|
+
"directory": "packages/mcp-server"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"bin": {
|
|
26
|
+
"free-api-list-mcp": "dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/server.d.ts",
|
|
31
|
+
"default": "./dist/server.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=24.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": true
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@free-api-list/catalog": "0.1.0",
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
48
|
+
"zod": "^4.6.7"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^26.6.11",
|
|
52
|
+
"tsx": "^4.23.15",
|
|
53
|
+
"typescript": "^7.0.2",
|
|
54
|
+
"vitest": "^5.1.2"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"start": "tsx src/index.ts",
|
|
58
|
+
"build": "tsc -p tsconfig.build.json",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"test": "vitest run --passWithNoTests",
|
|
61
|
+
"smoke": "node scripts/smoke-pack.mjs"
|
|
62
|
+
}
|
|
6
63
|
}
|