Skip to content

Commit 31305b6

Browse files
committed
fix: first docs vue-i18n mcp
1 parent 906ba30 commit 31305b6

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

docs/.vitepress/client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ async function main() {
4141
// List tools
4242
const tools = await client.listTools()
4343
console.log('list tools', tools)
44+
45+
// List resources
46+
const resources = await client.listResources()
47+
console.log('list resources', resources)
48+
const contents = await client.readResource({
49+
uri: 'vue-i18n://contents'
50+
})
51+
console.log('read resource', contents)
4452
}
4553

4654
main()

docs/.vitepress/config.mts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ViteMcp as mcp } from 'vite-plugin-mcp'
22
import { defineConfig } from 'vitepress'
33
import llmstxt from 'vitepress-plugin-llms'
44
import pkg from '../../package.json' with { type: 'json' }
5+
import mcpServer from './mcp'
56

67
import type { HeadConfig } from 'vitepress'
78

@@ -24,10 +25,7 @@ export default defineConfig({
2425
name: 'Vue I18n MCP Docs',
2526
version: pkg.version
2627
},
27-
mcpServerSetup(mcpServer, viteServer) {
28-
console.log('Setting up MCP server for Vue I18n docs...', viteServer.config.vitepress)
29-
return mcpServer
30-
}
28+
mcpServerSetup: mcpServer
3129
}
3230
)]
3331
},

docs/.vitepress/mcp.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from 'node:fs/promises'
2+
import path from 'node:path'
3+
4+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
5+
import type { ViteDevServer } from 'vite'
6+
import type { SiteConfig } from 'vitepress'
7+
8+
type Awaitable<T> = T | PromiseLike<T>;
9+
10+
export default function mcp(mcpServer: McpServer, viteServer: ViteDevServer): Awaitable<void | McpServer> {
11+
const vitepress = (viteServer.config as any).vitepress as SiteConfig
12+
console.log('Setting up MCP server for Vue I18n docs...', vitepress.userConfig.themeConfig)
13+
// mcpServer.resource('contents', 'vue-i18n://contents', async (uri) => {
14+
mcpServer.resource('contents', 'vue-i18n://contents', {
15+
uri: 'vue-i18n://contents',
16+
name: 'Vue I18n Contents',
17+
description: 'List of Contents for Vue I18n',
18+
}, async (uri) => {
19+
const filePath = path.resolve(import.meta.dirname, './dist/llms.txt')
20+
const content = await fs.readFile(filePath, 'utf-8')
21+
return {
22+
contents: [
23+
{
24+
uri,
25+
text: content,
26+
}
27+
]
28+
}
29+
})
30+
return mcpServer
31+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
"vitepress-plugin-llms": "^1.1.0",
164164
"vite-plugin-mcp": "^0.2.2",
165165
"@modelcontextprotocol/sdk": "^1.12.0",
166+
"vite": "^6.0.0",
166167
"vitest": "^2.1.5",
167168
"vue": "3.5.13",
168169
"vue-i18n": "workspace:*"

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)