Skip to content

Commit 77b3b9a

Browse files
committed
Update with new search API
1 parent c08f8a8 commit 77b3b9a

File tree

9 files changed

+166
-39
lines changed

9 files changed

+166
-39
lines changed

2slides-mcp-0.1.1.tgz

4.17 KB
Binary file not shown.

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
MIT License
2+
3+
Copyright (c) 2025
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.
22+
23+

README.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,65 @@
1-
2slides MCP Server (Node.js)
1+
## 2slides MCP Server
22

3-
Setup
4-
- Copy .env.example to .env and set API_KEY
5-
- Install deps: npm install
6-
- Dev run (stdio): npm run dev
7-
- Build: npm run build
8-
- Start: npm start
3+
Expose 2slides.com tools for MCP clients (e.g., Claude Desktop).
94

10-
Claude Desktop config example
5+
### Configure in Claude Desktop
6+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json` and add:
7+
```json
118
{
129
"mcpServers": {
1310
"2slides": {
14-
"command": "node",
15-
"args": [
16-
"/Users/julian/Workspace/you_are_funny/2slides-mcp/node_modules/.bin/tsx",
17-
"/Users/julian/Workspace/you_are_funny/2slides-mcp/src/server.ts"
18-
],
11+
"command": "npx",
12+
"args": ["2slides-mcp"],
1913
"env": {
20-
"API_KEY": "YOUR_API_KEY"
14+
"API_KEY": "YOUR_2SLIDES_API_KEY"
2115
}
2216
}
2317
}
2418
}
19+
```
20+
Then fully restart Claude Desktop. In a chat, open the tools panel and you should see the tools below.
2521

26-
Tools
27-
- slides_generate: POST /api/v1/slides/generate
28-
- jobs_get: GET /api/v1/jobs/{jobId}
22+
### Available Tools
23+
- `slides_generate` (POST /api/v1/slides/generate)
24+
- Args: `themeId` (string), `userInput` (string), `responseLanguage` (string)
25+
- Example:
26+
```json
27+
{
28+
"themeId": "st-1756528793701-fcg5fblt2",
29+
"userInput": "generate sample content",
30+
"responseLanguage": "English"
31+
}
32+
```
33+
34+
- `jobs_get` (GET /api/v1/jobs/{jobId})
35+
- Args: `jobId` (string)
36+
- Example:
37+
```json
38+
{ "jobId": "D8h9VYDGdTlZ6wWSEoctF" }
39+
```
40+
41+
- `themes_search` (GET /api/v1/themes/search)
42+
- Args: `query` (string), `limit` (number, optional, max 100)
43+
- Example:
44+
```json
45+
{ "query": "8 stages", "limit": 10 }
46+
```
47+
48+
- `templates_browse_url` (No API call)
49+
- Returns the templates page URL: `https://www.2slides.com/templates`
50+
51+
All tools return the 2slides API JSON as formatted text. Use `jobs_get` with the `jobId` from `slides_generate` to poll status or get the `downloadUrl` when available.
2952

30-
References
31-
- https://modelcontextprotocol.io/docs/develop/build-server
32-
- https://www.2slides.com
53+
### Troubleshooting (Claude Desktop)
54+
- If tools don’t appear in Claude, verify the config path is absolute and restart the app.
55+
- Check Claude MCP logs:
56+
```bash
57+
tail -n 50 -f ~/Library/Logs/Claude/mcp*.log
58+
```
59+
- For stdio MCP servers, avoid logging to stdout; this server only logs errors to stderr. See the official guidance below.
3360

61+
### References
62+
- Build an MCP server (official docs): https://modelcontextprotocol.io/docs/develop/build-server
63+
- 2slides: https://www.2slides.com
64+
- 2slides Templates: https://www.2slides.com/templates
3465

package-lock.json

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
{
2-
"name": "mcp-2slides-server",
3-
"version": "0.1.0",
2+
"name": "2slides-mcp",
3+
"version": "0.1.1",
44
"main": "index.js",
5+
"type": "module",
6+
"description": "MCP server exposing 2slides.com tools (slides generate, jobs get, themes search)",
7+
"keywords": ["mcp", "modelcontextprotocol", "2slides", "slides", "claude"],
8+
"license": "MIT",
9+
"author": "",
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/2slides/2slides-mcp.git"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/2slides/2slides-mcp/issues"
16+
},
17+
"homepage": "https://github.com/2slides/2slides-mcp#readme",
518
"scripts": {
619
"test": "echo \"Error: no test specified\" && exit 1",
720
"build": "tsc",
821
"start": "node dist/server.js",
9-
"dev": "tsx src/server.ts"
22+
"dev": "tsx src/server.ts",
23+
"prepare": "tsc"
1024
},
11-
"keywords": [],
12-
"author": "",
13-
"license": "ISC",
14-
"description": "",
15-
"type": "module",
25+
"bin": {
26+
"2slides-mcp": "dist/cli.js"
27+
},
28+
"files": [
29+
"dist",
30+
"README.md",
31+
"LICENSE"
32+
],
1633
"engines": {
1734
"node": ">=18"
1835
},
1936
"dependencies": {
2037
"@modelcontextprotocol/sdk": "^1.18.1",
38+
"@types/dotenv": "^6.1.1",
2139
"dotenv": "^17.2.2",
2240
"node-fetch": "^3.3.2",
2341
"zod": "^3.25.76"

src/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
import './server.js';
3+
4+

src/server.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import 'dotenv/config';
1+
import dotenv from 'dotenv';
22
import { z } from 'zod';
33
import fetch from 'node-fetch';
44
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
55
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
66

77
// Constants
88
const API_BASE_URL = 'https://www.2slides.com';
9+
dotenv.config();
910
const API_KEY = process.env.API_KEY ?? '';
1011

1112
if (!API_KEY) {
@@ -23,7 +24,7 @@ const GenerateArgs = {
2324
responseLanguage: z.string().min(1),
2425
};
2526

26-
mcp.tool('slides_generate', 'Generate slides with 2slides. Returns job info including jobId and downloadUrl when ready.', GenerateArgs, async (args, _extra) => {
27+
mcp.tool('slides_generate', 'Generate slides with 2slides. Returns job info including jobId and downloadUrl when ready.', GenerateArgs, async (args: any, _extra: any) => {
2728
const { themeId, userInput, responseLanguage } = args as z.infer<z.ZodObject<typeof GenerateArgs>>;
2829
const url = `${API_BASE_URL}/api/v1/slides/generate`;
2930
const res = await fetch(url, {
@@ -48,7 +49,7 @@ mcp.tool('slides_generate', 'Generate slides with 2slides. Returns job info incl
4849
// Tool: jobs_get -> GET /api/v1/jobs/{job-id}
4950
const JobArgs = { jobId: z.string().min(1) };
5051

51-
mcp.tool('jobs_get', 'Get job status/result by jobId from 2slides.', JobArgs, async (args, _extra) => {
52+
mcp.tool('jobs_get', 'Get job status/result by jobId from 2slides.', JobArgs, async (args: any, _extra: any) => {
5253
const { jobId } = args as z.infer<z.ZodObject<typeof JobArgs>>;
5354
const url = `${API_BASE_URL}/api/v1/jobs/${encodeURIComponent(jobId)}`;
5455
const res = await fetch(url, {
@@ -68,6 +69,34 @@ mcp.tool('jobs_get', 'Get job status/result by jobId from 2slides.', JobArgs, as
6869
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
6970
});
7071

72+
// Tool: themes_search -> GET /api/v1/themes/search
73+
const ThemesSearchArgs = {
74+
query: z.string().min(1),
75+
limit: z.number().int().positive().max(100).optional(),
76+
};
77+
78+
mcp.tool('themes_search', 'Search 2slides themes by query. Optional limit (max 100).', ThemesSearchArgs, async (args: any, _extra: any) => {
79+
const { query, limit } = args as z.infer<z.ZodObject<typeof ThemesSearchArgs>>;
80+
const search = new URLSearchParams({ query });
81+
if (typeof limit === 'number') search.set('limit', String(limit));
82+
const url = `${API_BASE_URL}/api/v1/themes/search?${search.toString()}`;
83+
const res = await fetch(url, {
84+
method: 'GET',
85+
headers: {
86+
Authorization: `Bearer ${API_KEY}`,
87+
'Content-Type': 'application/json',
88+
},
89+
});
90+
const data = await res.json();
91+
if (!res.ok) {
92+
return {
93+
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
94+
isError: true,
95+
};
96+
}
97+
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
98+
});
99+
71100
// Start server over stdio
72101
const transport = new StdioServerTransport();
73102
mcp.connect(transport).catch((err: unknown) => {

src/types/sdk-shims.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
declare module '@modelcontextprotocol/sdk/server/mcp' {
2+
export const McpServer: any;
3+
}
4+
5+
declare module '@modelcontextprotocol/sdk/server/stdio' {
6+
export const StdioServerTransport: any;
7+
}
8+
9+
10+
11+

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// See also https://aka.ms/tsconfig/module
1010
"module": "nodenext",
1111
"target": "es2022",
12-
"types": [],
12+
"types": ["node"],
1313
// For nodejs:
1414
// "lib": ["esnext"],
1515
// "types": ["node"],

0 commit comments

Comments
 (0)