feat: 初次提交
This commit is contained in:
185
src/tools/programming/docs.ts
Normal file
185
src/tools/programming/docs.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* Technical documentation query tools
|
||||
*/
|
||||
|
||||
import { mcpServer } from "../../server.js";
|
||||
|
||||
const DOCS_LINKS = {
|
||||
typescript: {
|
||||
official: "https://www.typescriptlang.org/docs/",
|
||||
handbook: "https://www.typescriptlang.org/docs/handbook/intro.html",
|
||||
api: "https://www.typescriptlang.org/docs/handbook/utility-types.html",
|
||||
},
|
||||
vue3: {
|
||||
official: "https://vuejs.org/",
|
||||
guide: "https://vuejs.org/guide/",
|
||||
api: "https://vuejs.org/api/",
|
||||
migration: "https://vuejs.org/guide/extras/migration-build.html",
|
||||
},
|
||||
bun: {
|
||||
official: "https://bun.sh/docs",
|
||||
runtime: "https://bun.sh/docs/runtime",
|
||||
api: "https://bun.sh/docs/api",
|
||||
test: "https://bun.sh/docs/test",
|
||||
},
|
||||
};
|
||||
|
||||
export function registerDocsTools(): void {
|
||||
// TypeScript docs
|
||||
mcpServer.registerTool(
|
||||
{
|
||||
name: "docs_typescript",
|
||||
description: "Get TypeScript documentation links and information",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
topic: {
|
||||
type: "string",
|
||||
description:
|
||||
'Specific topic to search for (e.g., "types", "interfaces", "generics")',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (args) => {
|
||||
const topic = args.topic as string | undefined;
|
||||
const links = DOCS_LINKS.typescript;
|
||||
|
||||
let response = `TypeScript Documentation:\n\n`;
|
||||
response += `Official Docs: ${links.official}\n`;
|
||||
response += `Handbook: ${links.handbook}\n`;
|
||||
response += `Utility Types API: ${links.api}\n\n`;
|
||||
|
||||
if (topic) {
|
||||
response += `Searching for: ${topic}\n\n`;
|
||||
response += `Common TypeScript topics:\n`;
|
||||
response += `- Types & Interfaces: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html\n`;
|
||||
response += `- Generics: https://www.typescriptlang.org/docs/handbook/2/generics.html\n`;
|
||||
response += `- Classes: https://www.typescriptlang.org/docs/handbook/2/classes.html\n`;
|
||||
response += `- Modules: https://www.typescriptlang.org/docs/handbook/2/modules.html\n`;
|
||||
response += `- Type Guards: https://www.typescriptlang.org/docs/handbook/2/narrowing.html\n`;
|
||||
} else {
|
||||
response += `Quick Links:\n`;
|
||||
response += `- Basic Types: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html\n`;
|
||||
response += `- Advanced Types: https://www.typescriptlang.org/docs/handbook/2/types-from-types.html\n`;
|
||||
response += `- Utility Types: https://www.typescriptlang.org/docs/handbook/utility-types.html\n`;
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: response,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Vue3 docs
|
||||
mcpServer.registerTool(
|
||||
{
|
||||
name: "docs_vue3",
|
||||
description: "Get Vue 3 documentation links and information",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
topic: {
|
||||
type: "string",
|
||||
description:
|
||||
'Specific topic (e.g., "composition", "reactivity", "components")',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (args) => {
|
||||
const topic = args.topic as string | undefined;
|
||||
const links = DOCS_LINKS.vue3;
|
||||
|
||||
let response = `Vue 3 Documentation:\n\n`;
|
||||
response += `Official Site: ${links.official}\n`;
|
||||
response += `Guide: ${links.guide}\n`;
|
||||
response += `API Reference: ${links.api}\n\n`;
|
||||
|
||||
if (topic) {
|
||||
response += `Searching for: ${topic}\n\n`;
|
||||
response += `Common Vue 3 topics:\n`;
|
||||
response += `- Composition API: https://vuejs.org/guide/extras/composition-api-faq.html\n`;
|
||||
response += `- Reactivity: https://vuejs.org/guide/essentials/reactivity-fundamentals.html\n`;
|
||||
response += `- Components: https://vuejs.org/guide/essentials/component-basics.html\n`;
|
||||
response += `- Props: https://vuejs.org/guide/components/props.html\n`;
|
||||
response += `- Events: https://vuejs.org/guide/components/events.html\n`;
|
||||
response += `- Lifecycle: https://vuejs.org/guide/essentials/lifecycle.html\n`;
|
||||
} else {
|
||||
response += `Quick Links:\n`;
|
||||
response += `- Getting Started: https://vuejs.org/guide/quick-start.html\n`;
|
||||
response += `- Composition API: https://vuejs.org/guide/extras/composition-api-faq.html\n`;
|
||||
response += `- Reactivity Fundamentals: https://vuejs.org/guide/essentials/reactivity-fundamentals.html\n`;
|
||||
response += `- Components Basics: https://vuejs.org/guide/essentials/component-basics.html\n`;
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: response,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Bun docs
|
||||
mcpServer.registerTool(
|
||||
{
|
||||
name: "docs_bun",
|
||||
description: "Get Bun documentation links and information",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
topic: {
|
||||
type: "string",
|
||||
description:
|
||||
'Specific topic (e.g., "runtime", "api", "test", "bundler")',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (args) => {
|
||||
const topic = args.topic as string | undefined;
|
||||
const links = DOCS_LINKS.bun;
|
||||
|
||||
let response = `Bun Documentation:\n\n`;
|
||||
response += `Official Docs: ${links.official}\n`;
|
||||
response += `Runtime: ${links.runtime}\n`;
|
||||
response += `API Reference: ${links.api}\n`;
|
||||
response += `Testing: ${links.test}\n\n`;
|
||||
|
||||
if (topic) {
|
||||
response += `Searching for: ${topic}\n\n`;
|
||||
response += `Common Bun topics:\n`;
|
||||
response += `- Runtime: https://bun.sh/docs/runtime\n`;
|
||||
response += `- File System: https://bun.sh/docs/api/file-io\n`;
|
||||
response += `- HTTP Server: https://bun.sh/docs/api/http\n`;
|
||||
response += `- SQLite: https://bun.sh/docs/api/sqlite\n`;
|
||||
response += `- Testing: https://bun.sh/docs/test\n`;
|
||||
response += `- Bundler: https://bun.sh/docs/bundler\n`;
|
||||
} else {
|
||||
response += `Quick Links:\n`;
|
||||
response += `- Getting Started: https://bun.sh/docs/installation\n`;
|
||||
response += `- Runtime API: https://bun.sh/docs/runtime\n`;
|
||||
response += `- HTTP Server: https://bun.sh/docs/api/http\n`;
|
||||
response += `- File System: https://bun.sh/docs/api/file-io\n`;
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: response,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user