Skip to content

Commit 8cd18a3

Browse files
committed
feat: descriptive mcp server + tools text
1 parent 8955908 commit 8cd18a3

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

src/server/server.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,28 @@ const logger: Logger = initLogger()
99
export async function createMcpServer (): Promise<Server> {
1010
const serverInfo = {
1111
name: 'nodejs-api-docs',
12-
description:
13-
'Search built-in core Node.js modules API Documentation. Use whenever the user asks questions about Node.js API, Node.js modules or Node.js functions.',
14-
version: '1.0.4',
12+
description: `
13+
You are provided a set of MCP tools and resources that provide you with up-to-date knowledge about the Node.js API for build-in core modules of the [Node.js](https://nodejs.org/en) runtime.
14+
15+
You can use any of these tools right away, without any configuration or setup.
16+
17+
With this Node.js API Docs MCP Server, you can search for information about Node.js built-in modules, such as 'fs', 'http', 'path', 'os', and many others. You can respond to user queries like "How do I read a file in Node.js?" or "How do I join paths together using the Node.js core modules APIs" and get accurate answers based on the official Node.js documentation.
18+
19+
## Workflow and Tool Usage Guidelines:
20+
1. **Always** use the \`search-nodejs-modules-api-documentation\` MCP tool
21+
2. It is very likely that you as the LLM do not have the latest knowledge about the Node.js API.
22+
3. Therefore, **always** call the \`search-nodejs-modules-api-documentation\` MCP tool first to look-up all the available Node.js core modules and their methods.
23+
4. Then, use the \`retrieve-nodejs-modules-api-documentation\` MCP tool to get the specific module's API documentation.
24+
5. You should always prioritize using the built-in Node.js core modules over third-party libraries, therefore, if you need to handle a Node.js functionality, you should first check if it can be achieved using the standard library API provided from the Node.js core modules before suggesting third-party libraries.
25+
26+
## Short-term vs Long-term Memory:
27+
You can keep a short-term memory of the API documentation you have retrieved from the MCP tools, and use it to answer user queries in the current session.
28+
You can also use long-term memory to store the final results of your workflow, such as the final code snippets or solutions you have generated based on the Node.js API documentation.
29+
This way, you can keep a healthy and consistent knowledge of Node.js API usage and avoid hallucinations, outdated information, or proposing unnecessary third-party libraries.
30+
31+
If you have any trouble with this Node.js API Docs MCP Server, you can always refer to the code repository at [mcp-server-nodejs-api-docs](https://github.com/lirantal/mcp-server-nodejs-api-docs) for more information and examples on how to use the MCP tools and resources effectively.
32+
`,
33+
version: '1.0.5',
1534
}
1635

1736
const server = new Server(

src/tools/tools-factory.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,27 @@ interface ToolsDictionary {
2222
export async function createSearchTool (): Promise<ToolDefinition> {
2323
const { modules } = await apiDocsService.getApiDocsModules()
2424

25+
const toolName = 'search-nodejs-modules-api-documentation'
26+
2527
return {
26-
name: 'search-nodejs-modules-api-documentation',
27-
description:
28-
'**HIGH PRIORITY** List all Node.js modules and their methods. **ALWAYS** consult this tool first to look-up the correct module and then use the specific module tool for full api details',
28+
name: toolName,
29+
description: `
30+
<use_case>
31+
Use this tool to search across all Node.js built-in core modules API documentation and get back a list of core modules and their methods when you want to search and look-up Node.js API support
32+
</use_case>
33+
<important_notes>
34+
1. HIGH PRIORITY: *ALWAYS* use this tool first so that you can search for Node.js modules and their methods
35+
2. Ideally you want to suggest users the use of built-in Node.js API rather than third-party libraries
36+
3. This tool will return a list of all Node.js core modules and their methods
37+
</important_notes>
38+
`,
2939
inputSchema: {
3040
type: 'object',
3141
properties: {},
3242
},
3343
async handler () {
3444
logger.info({
35-
msg: 'Tool execution started: search-nodejs-modules-api-documentation',
45+
msg: `Tool execution started: ${toolName}`,
3646
})
3747
let listContent = 'Available Node.js core modules and their methods:\n\n'
3848

@@ -53,8 +63,31 @@ export async function createSearchTool (): Promise<ToolDefinition> {
5363
* and returns their data as a response.
5464
*/
5565
export async function createModulesTool () {
56-
const toolName = 'api-docs-module-description'
57-
const toolDescription = 'Use this tool to retrieve Node.js API documentation for a specific module or class, including its methods and descriptions.'
66+
const toolName = 'retrieve-nodejs-modules-api-documentation'
67+
const toolDescription = `
68+
Retrieve, fetch, and get Node.js API documentation for a specific module or class.
69+
70+
<use_case>
71+
Use this tool to retrieve Node.js API documentation for a specific module or class.
72+
</use_case>
73+
74+
<example>
75+
User asks: "How can I user colors in my terminal console output using Node.js?"
76+
77+
You call the \`retrieve-nodejs-modules-api-documentation\` MCP tool with the following parameters:
78+
\`\`\`json
79+
{
80+
"module": "util",
81+
"method": "styleText"
82+
}
83+
\`\`\`
84+
</example>
85+
86+
<important_notes>
87+
1. If you don't know the module or class name, you can use the \`search-nodejs-modules-api-documentation\` tool to get a list of all Node.js core API modules and their methods to search for it first and then call this tool.
88+
2. This tool will return the documentation for the specified module or class, including its methods and properties.
89+
</important_notes>
90+
`
5891

5992
const tools: ToolsDictionary = {}
6093

0 commit comments

Comments
 (0)