返回 slidev
mcp.md
根目录 / docs / features / mcp.md
1 ---
2 relates:
3 - guide/work-with-ai
4 - Model Context Protocol: https://modelcontextprotocol.io/
5 - features/vscode-extension
6 since: v52.17.0
7 tags: [editor, tool]
8 description: |
9 Built-in MCP server that lets AI agents inspect, edit, reorder, and navigate your slides.
10 ---
11
12 # MCP Server
13
14 Slidev ships a built-in [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server, so any MCP-capable AI agent (Claude Code, Codex, Cursor, VS Code Copilot, etc.) can work with your slides through structured tools instead of raw text edits — reading slides, updating content and notes, inserting/removing/reordering slides, and even driving the live presentation.
15
16 ## Via the Dev Server
17
18 When the dev server is running, the MCP server is available over HTTP (streamable transport) at:
19
20 ```
21 http://localhost:<port>/__mcp
22 ```
23
24 For example, register it with your agent:
25
26 ::: code-group
27
28 ```bash [Claude Code]
29 claude mcp add --transport http slidev http://localhost:3030/__mcp
30 ```
31
32 ```json [VS Code / Cursor]
33 {
34 "mcpServers": {
35 "slidev": {
36 "type": "http",
37 "url": "http://localhost:3030/__mcp"
38 }
39 }
40 }
41 ```
42
43 :::
44
45 With the dev server connected, agents can also use the `slidev-goto-slide` tool to navigate all connected browsers to a slide — handy for visually verifying a slide right after editing it. Edits made through the MCP tools are written back to your markdown files and hot-reloaded instantly.
46
47 To disable the endpoint, set in your headmatter:
48
49 ```yaml
50 ---
51 mcp: false
52 ---
53 ```
54
55 ## Via Stdio
56
57 Without a dev server, you can start a standalone MCP server over stdio, operating directly on the markdown files:
58
59 ```bash
60 slidev mcp [entry]
61 ```
62
63 For example:
64
65 ```json
66 {
67 "mcpServers": {
68 "slidev": {
69 "command": "npx",
70 "args": ["slidev", "mcp", "slides.md"]
71 }
72 }
73 }
74 ```
75
76 ## Available Tools
77
78 | Tool | Description |
79 | --------------------- | -------------------------------------------------------------------------------------------------- |
80 | `slidev-get-info` | Deck overview: entry file, title, slide count, markdown files, dev server URL and current position |
81 | `slidev-list-slides` | List all slides with number, title, layout, and source file |
82 | `slidev-get-slide` | Full source of one slide: frontmatter, content, and note |
83 | `slidev-update-slide` | Update the content, note, and/or frontmatter of a slide |
84 | `slidev-insert-slide` | Insert a new slide after an existing one |
85 | `slidev-remove-slide` | Remove a slide |
86 | `slidev-move-slide` | Move a slide before/after another one to reorder the deck |
87 | `slidev-goto-slide` | Navigate the live presentation to a slide (dev server only) |
88
89 Slides are addressed by their rendered 1-based number, matching the slide numbers shown in the presentation.
90
90 lines MARKDOWN