@pipeworx/mcp-catfacts 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 +36 -0
- package/package.json +10 -0
- package/src/index.ts +145 -0
- package/tsconfig.json +9 -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,36 @@
|
|
|
1
|
+
# @pipeworx/mcp-catfacts
|
|
2
|
+
|
|
3
|
+
MCP server for the [Cat Facts API](https://catfact.ninja) — random cat facts and cat breed listings. Free, no auth required.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | Description |
|
|
8
|
+
|------|-------------|
|
|
9
|
+
| `get_fact` | Get a single random cat fact |
|
|
10
|
+
| `list_breeds` | List cat breeds with country, origin, coat, and pattern |
|
|
11
|
+
| `get_facts` | Get multiple random cat facts |
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Add to your MCP client config:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"catfacts": {
|
|
21
|
+
"type": "url",
|
|
22
|
+
"url": "https://gateway.pipeworx.io/catfacts"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## CLI Usage
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx @anthropic-ai/mcp-client https://gateway.pipeworx.io/catfacts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
package/package.json
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cat Facts MCP — wraps Cat Facts API (free, no auth)
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* - get_fact: Get a random cat fact
|
|
6
|
+
* - list_breeds: List cat breeds
|
|
7
|
+
* - get_facts: Get multiple random cat facts
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface McpToolDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object';
|
|
15
|
+
properties: Record<string, unknown>;
|
|
16
|
+
required?: string[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface McpToolExport {
|
|
21
|
+
tools: McpToolDefinition[];
|
|
22
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const BASE_URL = 'https://catfact.ninja';
|
|
26
|
+
|
|
27
|
+
type RawFact = {
|
|
28
|
+
fact: string;
|
|
29
|
+
length: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type RawFactsResponse = {
|
|
33
|
+
current_page: number;
|
|
34
|
+
data: RawFact[];
|
|
35
|
+
total: number;
|
|
36
|
+
per_page: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type RawBreed = {
|
|
40
|
+
breed: string;
|
|
41
|
+
country: string;
|
|
42
|
+
origin: string;
|
|
43
|
+
coat: string;
|
|
44
|
+
pattern: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type RawBreedsResponse = {
|
|
48
|
+
current_page: number;
|
|
49
|
+
data: RawBreed[];
|
|
50
|
+
total: number;
|
|
51
|
+
per_page: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function formatFact(f: RawFact) {
|
|
55
|
+
return { fact: f.fact, length: f.length };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function formatBreed(b: RawBreed) {
|
|
59
|
+
return {
|
|
60
|
+
breed: b.breed,
|
|
61
|
+
country: b.country,
|
|
62
|
+
origin: b.origin,
|
|
63
|
+
coat: b.coat,
|
|
64
|
+
pattern: b.pattern,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const tools: McpToolExport['tools'] = [
|
|
69
|
+
{
|
|
70
|
+
name: 'get_fact',
|
|
71
|
+
description: 'Get a single random cat fact.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'list_breeds',
|
|
79
|
+
description: 'List cat breeds with details such as country, origin, coat, and pattern.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
limit: {
|
|
84
|
+
type: 'number',
|
|
85
|
+
description: 'Number of breeds to return. Defaults to 10.',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'get_facts',
|
|
92
|
+
description: 'Get multiple random cat facts.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
limit: {
|
|
97
|
+
type: 'number',
|
|
98
|
+
description: 'Number of facts to return. Defaults to 5.',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
106
|
+
switch (name) {
|
|
107
|
+
case 'get_fact':
|
|
108
|
+
return getFact();
|
|
109
|
+
case 'list_breeds':
|
|
110
|
+
return listBreeds((args.limit as number | undefined) ?? 10);
|
|
111
|
+
case 'get_facts':
|
|
112
|
+
return getFacts((args.limit as number | undefined) ?? 5);
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function getFact() {
|
|
119
|
+
const res = await fetch(`${BASE_URL}/fact`);
|
|
120
|
+
if (!res.ok) throw new Error(`Cat Facts API error: ${res.status}`);
|
|
121
|
+
const data = (await res.json()) as RawFact;
|
|
122
|
+
return formatFact(data);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function listBreeds(limit: number) {
|
|
126
|
+
const res = await fetch(`${BASE_URL}/breeds?limit=${limit}`);
|
|
127
|
+
if (!res.ok) throw new Error(`Cat Facts API error: ${res.status}`);
|
|
128
|
+
const data = (await res.json()) as RawBreedsResponse;
|
|
129
|
+
return {
|
|
130
|
+
total: data.total,
|
|
131
|
+
breeds: data.data.map(formatBreed),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function getFacts(limit: number) {
|
|
136
|
+
const res = await fetch(`${BASE_URL}/facts?limit=${limit}`);
|
|
137
|
+
if (!res.ok) throw new Error(`Cat Facts API error: ${res.status}`);
|
|
138
|
+
const data = (await res.json()) as RawFactsResponse;
|
|
139
|
+
return {
|
|
140
|
+
total: data.total,
|
|
141
|
+
facts: data.data.map(formatFact),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default { tools, callTool } satisfies McpToolExport;
|