temba-mcp 0.0.1 → 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/cli.js +3 -15
- package/mcp.js +48 -1
- package/package.json +9 -3
- package/searchDocs.js +9 -0
- package/version.js +1 -0
package/cli.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { startMcpServer } from './mcp.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
console.error('✨ Temba Docs MCP starting...')
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ensure = (condition = false, message) => {
|
|
8
|
-
if (!condition) {
|
|
9
|
-
console.error(message)
|
|
10
|
-
process.exit(1)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
console.log('\n✨ Temba Docs MCP')
|
|
15
|
-
|
|
16
|
-
go()
|
|
17
|
-
|
|
18
|
-
console.log('')
|
|
6
|
+
startMcpServer().catch(console.error)
|
package/mcp.js
CHANGED
|
@@ -1 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { searchDocs } from './searchDocs.js'
|
|
5
|
+
import { version } from './version.js'
|
|
6
|
+
|
|
7
|
+
export const startMcpServer = async () => {
|
|
8
|
+
const server = new McpServer({
|
|
9
|
+
name: 'temba-docs-mcp',
|
|
10
|
+
version,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// Fetch the index once on startup
|
|
14
|
+
let index = []
|
|
15
|
+
const searchIndexUrl = 'https://docs.temba.io/search-index.json'
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(searchIndexUrl)
|
|
18
|
+
index = await response.json()
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error('Failed to fetch ' + searchIndexUrl, e)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Register the tool
|
|
24
|
+
server.tool(
|
|
25
|
+
'search_docs',
|
|
26
|
+
'Search the library documentation',
|
|
27
|
+
{ query: z.string() },
|
|
28
|
+
async ({ query }) => {
|
|
29
|
+
const results = searchDocs(query, index).slice(0, 5) // Limit to top 5 results
|
|
30
|
+
|
|
31
|
+
if (results.length === 0) {
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: 'text', text: 'No documentation found for your query.' }],
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
content: results.map((page) => ({
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: `Title: ${page.title}\nURL: ${page.url}\n\nContent:\n${page.content}`,
|
|
41
|
+
})),
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
const transport = new StdioServerTransport()
|
|
47
|
+
await server.connect(transport)
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "temba-mcp",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "MCP for Temba documentation",
|
|
5
5
|
"author": "Bouwe (https://bouwe.io)",
|
|
6
6
|
"scripts": {
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"files": [
|
|
14
14
|
"cli.js",
|
|
15
|
-
"mcp.js"
|
|
16
|
-
|
|
15
|
+
"mcp.js",
|
|
16
|
+
"searchDocs.js",
|
|
17
|
+
"version.js"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "0.4.0",
|
|
21
|
+
"zod": "4.4.3"
|
|
22
|
+
}
|
|
17
23
|
}
|
package/searchDocs.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const searchDocs = (query, index) => {
|
|
2
|
+
const lowerQuery = query.toLowerCase()
|
|
3
|
+
return index.filter(
|
|
4
|
+
(page) =>
|
|
5
|
+
page.content.toLowerCase().includes(lowerQuery) ||
|
|
6
|
+
page.title.toLowerCase().includes(lowerQuery) ||
|
|
7
|
+
(page.keywords && page.keywords.some((k) => k.toLowerCase().includes(lowerQuery))),
|
|
8
|
+
)
|
|
9
|
+
}
|
package/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = '0.1.0'
|