@pipeworx/mcp-advice 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 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-advice
2
+
3
+ MCP server for the [Advice Slip API](https://api.adviceslip.com) — get random advice, search advice slips, and look up by ID. Free, no auth required.
4
+
5
+ ## Tools
6
+
7
+ | Tool | Description |
8
+ |------|-------------|
9
+ | `random_advice` | Get a random piece of advice |
10
+ | `search_advice` | Search for advice slips by keyword |
11
+ | `get_advice` | Get a specific advice slip by ID |
12
+
13
+ ## Quick Start
14
+
15
+ Add to your MCP client config:
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "advice": {
21
+ "type": "url",
22
+ "url": "https://gateway.pipeworx.io/advice"
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## CLI Usage
29
+
30
+ ```bash
31
+ npx @anthropic-ai/mcp-client https://gateway.pipeworx.io/advice
32
+ ```
33
+
34
+ ## License
35
+
36
+ MIT
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@pipeworx/mcp-advice",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "advice"],
7
+ "devDependencies": {
8
+ "typescript": "^5.7.0"
9
+ }
10
+ }
package/src/index.ts ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Advice MCP — wraps Advice Slip API (free, no auth)
3
+ *
4
+ * Tools:
5
+ * - random_advice: Get a random piece of advice
6
+ * - search_advice: Search for advice slips by keyword
7
+ * - get_advice: Get a specific advice slip by ID
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://api.adviceslip.com';
26
+
27
+ type RawAdviceSlip = {
28
+ id: number;
29
+ advice: string;
30
+ };
31
+
32
+ type RawRandomResponse = {
33
+ slip: RawAdviceSlip;
34
+ };
35
+
36
+ type RawSearchResponse = {
37
+ total_results: string;
38
+ query: string;
39
+ slips: RawAdviceSlip[] | string;
40
+ message?: { type: string; text: string };
41
+ };
42
+
43
+ type RawGetResponse = {
44
+ slip: RawAdviceSlip;
45
+ };
46
+
47
+ function formatSlip(slip: RawAdviceSlip) {
48
+ return {
49
+ id: slip.id,
50
+ advice: slip.advice,
51
+ };
52
+ }
53
+
54
+ const tools: McpToolExport['tools'] = [
55
+ {
56
+ name: 'random_advice',
57
+ description: 'Get a random piece of advice from the Advice Slip API.',
58
+ inputSchema: {
59
+ type: 'object',
60
+ properties: {},
61
+ },
62
+ },
63
+ {
64
+ name: 'search_advice',
65
+ description: 'Search for advice slips containing a specific keyword or phrase.',
66
+ inputSchema: {
67
+ type: 'object',
68
+ properties: {
69
+ query: {
70
+ type: 'string',
71
+ description: 'Keyword or phrase to search for within advice text.',
72
+ },
73
+ },
74
+ required: ['query'],
75
+ },
76
+ },
77
+ {
78
+ name: 'get_advice',
79
+ description: 'Get a specific advice slip by its numeric ID.',
80
+ inputSchema: {
81
+ type: 'object',
82
+ properties: {
83
+ id: {
84
+ type: 'number',
85
+ description: 'The numeric ID of the advice slip to retrieve.',
86
+ },
87
+ },
88
+ required: ['id'],
89
+ },
90
+ },
91
+ ];
92
+
93
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
94
+ switch (name) {
95
+ case 'random_advice':
96
+ return randomAdvice();
97
+ case 'search_advice':
98
+ return searchAdvice(args.query as string);
99
+ case 'get_advice':
100
+ return getAdvice(args.id as number);
101
+ default:
102
+ throw new Error(`Unknown tool: ${name}`);
103
+ }
104
+ }
105
+
106
+ async function randomAdvice() {
107
+ const res = await fetch(`${BASE_URL}/advice`);
108
+ if (!res.ok) throw new Error(`Advice Slip API error: ${res.status}`);
109
+
110
+ const data = (await res.json()) as RawRandomResponse;
111
+ return formatSlip(data.slip);
112
+ }
113
+
114
+ async function searchAdvice(query: string) {
115
+ const res = await fetch(`${BASE_URL}/advice/search/${encodeURIComponent(query)}`);
116
+ if (!res.ok) throw new Error(`Advice Slip API error: ${res.status}`);
117
+
118
+ const data = (await res.json()) as RawSearchResponse;
119
+
120
+ // API returns { message: { type: "notice", text: "..." } } when no results found
121
+ if (data.message) {
122
+ return { total_results: 0, query, slips: [] };
123
+ }
124
+
125
+ const slips = Array.isArray(data.slips) ? data.slips : [];
126
+
127
+ return {
128
+ total_results: parseInt(data.total_results, 10),
129
+ query: data.query,
130
+ slips: slips.map(formatSlip),
131
+ };
132
+ }
133
+
134
+ async function getAdvice(id: number) {
135
+ const res = await fetch(`${BASE_URL}/advice/${id}`);
136
+ if (!res.ok) throw new Error(`Advice Slip API error: ${res.status}`);
137
+
138
+ const data = (await res.json()) as RawGetResponse;
139
+ return formatSlip(data.slip);
140
+ }
141
+
142
+ export default { tools, callTool } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true
7
+ },
8
+ "include": ["src"]
9
+ }