🌟 MCP内部Wiki服务器
](https://github.com/yourusername/mcp-internal-wiki)  ](https://nodejs.org/)
将您的内部知识直接连接到IDE
🔍 什么是MCP Wiki服务器?
MCP内部Wiki服务器是您公司知识库和开发环境之间的专用桥梁。使用模型上下文协议(MCP),它能够 无缝访问文档 就在你需要的地方——在你的编辑器里。
💡 主控程序 (模型上下文协议)是将上下文信息集成到人工智能辅助开发环境中的开放标准。
✨ 为什么使用MCP Wiki服务器?
🚀 提高生产力
- 即时知识访问:IDE和浏览器之间不再进行上下文切换
- 一致的信息:每个团队成员都可以访问相同的最新文档
- 缩短入职时间:新开发人员可以直接在他们的工作流程中查找信息
🔄 运作原理
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
│ │ │ │ │ │
│ Your Wiki │◄────┤ MCP Server │◄────┤ VS Code │
│ Sources │ │ │ │ Extension │
│ │ │ │ │ │
└────────────────┘ └────────────────┘ └────────────────┘
^ │
│ │
└──────────────────────────────────────────────┘
Query & Response Flow🎯 主要特点
- 📚 多源集成:同时连接到多个wiki平台
- 🔍 内容相关式搜索:使用高级查询功能准确找到所需内容
- 🚀 代码转换:将wiki内容转换为多种语言的可执行代码
- 🏗️ 项目生成:从文档中生成完整的项目结构
- 🎨 模板系统:使用Handlebars模板生成一致的代码
- 🤖 AI驱动:利用人工智能提供商进行智能代码生成和转换
- 🧩 可扩展架构:根据您的特定需求添加自定义源和适配器
- 🛠️ 平台无关:适用于任何兼容MCP的编辑器
- 🔒 注重隐私:所有内容都保留在您的环境中;没有外部API调用
- 🔐 安全认证:支持私有wiki的基本、令牌和自定义身份验证方法
- ⚡ 闪电般快速:通过多级缓存、连接池和批处理进行高级性能优化
- 🚀 企业规模:通过智能资源管理和实时监控处理数百万个维基页面
- 📊 性能监控:实时指标收集,包括缓存命中率、响应时间和吞吐量跟踪
📦 快速开始
# Install globally
npm install -g mcp-internal-wiki
# Run the server
mcp-wiki-server🔧 设置和配置
1.安装
选择您喜欢的安装方法:
📥 Local Installation
# Clone the repository
git clone https://github.com/yourusername/mcp-internal-wiki.git
cd mcp-internal-wiki
# Install dependencies
npm install
# Build the project
npm run build🌐 Global Installation
# Install globally
npm install -g mcp-internal-wiki
# Run the server
mcp-wiki-server⚡ Quick Install (no installation)
npx mcp-internal-wiki❄️ NixOS Installation
# Install via the flake
nix profile install github:yourusername/mcp-internal-wiki
# Or run without installing
nix run github:yourusername/mcp-internal-wiki请参阅 NixOS安装指南 了解更多详情。
2.配置Wiki源
创建或编辑 mcp.config.json 要包含您的wiki URL,请执行以下操作:
{
"wikiUrls": [
"https://your-company-wiki.example.com",
"https://your-team-gitbook.example.io",
"https://private-confluence.example.com/wiki"
],
"cacheTimeoutMinutes": 30
}3.配置私有维基的身份验证
对于需要身份验证的wiki,添加 auth 部分到您的 mcp.config.json:
{
"wikiUrls": [
"https://your-company-wiki.example.com",
"https://your-team-gitbook.example.io",
"https://private-confluence.example.com/wiki"
],
"cacheTimeoutMinutes": 30,
"auth": [
{
"urlPattern": "example\\.confluence\\.com",
"type": "basic",
"username": "username",
"password": "password",
"comment": "Replace with actual credentials for your Confluence instance"
},
{
"urlPattern": "example\\.sharepoint\\.com",
"type": "token",
"token": "your-access-token",
"comment": "Replace with actual token for your SharePoint instance"
},
{
"urlPattern": "api\\.github\\.com",
"type": "custom",
"headerName": "Authorization",
"headerValue": "token ghp_yourgithubpersonalaccesstoken",
"comment": "For accessing private GitHub repositories"
}
]
}支持的身份验证类型:
basic:HTTP基本身份验证的用户名和密码token:承载令牌身份验证custom:自定义标头身份验证oauth:OAuth 2.0身份验证(高级配置)
4.VS代码集成
要使用带有VS代码的MCP内部Wiki服务器:
- 安装副驾驶MCP扩展: 市场链接
- 配置MCP服务器:
- 创建 .vscode/mcp.json 在您的工作区根目录中:
{
"servers": {
"my-mcp-wiki-server": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/dist/server.js"],
"env": {
"MCP_CONFIG_PATH": "${workspaceFolder}/mcp.config.json"
}
}
}
}- 对于全局安装,请使用
"command": "mcp-wiki-server". - 对于npx,使用
"command": "npx", "args": ["mcp-internal-wiki"].
- 重新启动VS代码 以应用该配置。
- 测试集成:
- 打开一个markdown文件,键入与wiki内容相关的查询。 - MCP扩展应该提供来自wiki源的补全或上下文。
- 故障排除:
- 检查VS代码输出面板(MCP通道)的日志。 - 确保MCP服务器正在运行 mcp.config.json 是有效的。 - 看 TESTING_VS_CODE.md 和 VSCODE_QUICK_REFERENCE.md 以获得更多帮助。
VS代码集成和测试
设置
- 从VS代码市场安装副驾驶MCP扩展。
- 创建
.vscode/mcp.json在您的工作区根目录中:
{
"servers": {
"my-mcp-wiki-server": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/dist/server.js"],
"env": {
"MCP_CONFIG_PATH": "${workspaceFolder}/mcp.config.json"
}
}
}
}- 对于全局安装,请使用
"command": "mcp-wiki-server". - 对于npx,使用
"command": "npx", "args": ["mcp-internal-wiki"].
- 重新启动VS Code以应用配置。
测试
- 打开一个markdown文件,键入与wiki内容相关的查询。
- MCP扩展应该提供来自wiki源的补全或上下文。
- 跑
npm run test:simple或npm run test:interactive用于CLI验证。
故障排除
- 检查VS代码输出面板(MCP通道)的日志。
- 确保MCP服务器正在运行
mcp.config.json是有效的。 - 看
TESTING_VS_CODE.md和VSCODE_QUICK_REFERENCE.md以获得更多帮助。
🚀 内容转换和代码生成
MCP内部Wiki服务器包括强大的转换功能,可以将您的Wiki文档转换为可执行代码和完整的项目结构。
可用的MCP工具
服务器通过标准MCP协议提供这些转换工具:
🔄 transform_content
将wiki内容或markdown转换为任何编程语言的可执行代码。
VS代码中的用法:
- 在编辑器中选择wiki内容
- 通过MCP工具界面访问
- 选择目标语言和框架
参数:
content:要转换的Wiki内容或markdowntargetLanguage:目标编程语言(typescript、python、javascript等)framework:可选框架(express、fastapi、react等)projectType:可选项目类型(api、库、cli等)
🏗️ generate_code
使用模板和人工智能生成从维基内容生成代码。
参数:
content:生成代码的Wiki文档codeType:要生成的代码类型(dockerfile、typescript、python、yaml等)templateName:要使用的可选模板(express服务器、typescript类等)
特征:
- 基于模板的生成:使用Handlebars模板实现一致的输出
- AI增强:利用配置的AI提供程序进行智能代码生成
- 多格式支持:生成Dockerfiles、package.json、TypeScript类等
📁 generate_project
从wiki文档生成完整的项目结构。
参数:
content:描述项目要求的Wiki内容projectType:项目类型(express api、react-app、cli工具等)language:编程语言(typescript、python、javascript等)
能力:
- 全项目脚手架:创建完整的目录结构
- 多文件生成:生成所有必要的项目文件
- 最佳实践遵循既定的模式和惯例
模板系统
转换系统使用Handlebars模板来生成一致的代码:
可用模板:
typescript-class.hbs-TypeScript类定义express-server.hbs-Express.js服务器设置dockerfile.hbs-Docker容器化package-json.hbs-Node.js包配置readme.hbs-项目文件
自定义模板: 在中添加您自己的模板 /templates 目录使用Handlebars语法。
人工智能集成
转型系统与多个AI提供商集成:
- OpenAI GPT-4o:高级代码生成和分析
- 谷歌双子座2.5 Pro:智能内容转换
- Azure OpenAI:企业级AI能力
- 克劳德:用于精确代码生成的Anthropic人工智能
配置在 mcp.config.json:
{
"ai": {
"enabled": true,
"providers": {
"openai": {
"apiKey": "your-openai-api-key",
"model": "gpt-4o"
},
"gemini": {
"apiKey": "your-gemini-api-key",
"model": "gemini-2.5-pro"
}
},
"primaryProvider": "openai"
}
}转换工作流示例
1.API文件→ 快递服务器
# User Authentication API
Create a REST API with JWT authentication
- POST /auth/login
- POST /auth/register
- GET /auth/profile↓ 变压器内容 随着 targetLanguage: "typescript" 和 framework: "express"
// Generated Express.js server with JWT authentication
import express from 'express';
import jwt from 'jsonwebtoken';
// ... complete implementation2.部署指南→ Docker配置
# Deployment Requirements
- Node.js 18 runtime
- PostgreSQL database
- Redis for caching
- Environment variables for config↓ generate_code 随着 codeType: "dockerfile"
FROM node:18-alpine
RUN apk add --no-cache postgresql-client redis
# ... complete Docker configuration3.项目规范→ 全脚手架
# CLI Tool Requirements
TypeScript-based command-line tool for file processing
- File input/output operations
- Configuration via CLI arguments
- Unit testing with Jest↓ 发电项目 随着 projectType: "cli-tool" 和 language: "typescript"
project/
├── src/
│ ├── cli.ts
│ ├── processor.ts
│ └── config.ts
├── tests/
├── package.json
├── tsconfig.json
└── README.md测试转换功能
测试转换能力:
# Run transformation tests
npm run test:transform
# Test individual transformation methods
node tests/test-mcp-tools.js🧩 代理体系结构
MCP内部Wiki服务器现在为所有核心功能使用基于代理的模块化架构:
- WikiContentAgent:获取和过滤查询的wiki内容
- 航空代理:使用AI提供商对内容相关性进行评分
- 维基索引代理:管理(重新)构建wiki搜索索引
如何使用代理
- 在中使用代理管理器
src/agents/index.ts访问和编排代理 - 使用以下工具运行基于代理的测试
just agent-test或通过Nix外壳 - Docker POC中提供了用于集成测试的代理端点
看 COPILOT_INSTRUCTIONS.md 了解完整的代理使用和开发指南。
🏗️ 用例
- 开发者文档:即时访问API引用、代码标准和模式
- 入职:帮助新团队成员在不离开IDE的情况下查找信息
- 知识管理:创建分布式知识库的统一接口
- DevOps实践:快速参考基础设施模式和操作程序
⚡ 性能和可扩展性
企业级性能优化
MCP Wiki Server包括用于处理大规模部署的高级性能优化功能:
- 🚀 多级缓存:具有自动分配功能的智能缓存管理:
- 用于大型wiki页面的内容缓存(占内存的60%) - 页面信息的元数据缓存(占内存的30%) - 搜索结果的查询缓存(占内存的10%) - LRU驱逐,可配置大小和物品限制
- 🔍 全文搜索索引:实时搜索功能:
- 以最小的性能影响重建后台索引 - 拼写错误和部分查询的模糊搜索匹配 - 内存优化的倒排索引结构 - 可配置的索引间隔
- ⚡ 基于优先级的批处理:后台作业管理:
- 可配置的并发限制,以实现最佳资源使用 - 具有指数回退的自动重试机制 - 关键任务与后台任务的优先级队列 - 重复作业以防止冗余处理
- 🔄 HTTP连接池高效的网络资源管理:
- 连接重用以减少开销 - 自动故障转移和运行状况监控 - 可配置的池大小和超时 - 资源清理和垃圾收集
- 📊 实时性能监控:综合指标收集:
- 缓存命中率和内存使用跟踪 - 具有慢速查询检测的响应时间监控 - 请求吞吐量和错误率跟踪 - 性能仪表板和警报
性能测试
运行全面的性能测试以验证您的部署:
# Test cache performance (immediate - no build required)
npm run test:cache
# Full performance test suite (requires build)
npm run build && npm run test:performance
# Load testing with concurrent users
npm run test:load
# Performance CLI tools
npm run perf benchmark
npm run perf monitor大型部署的配置
在您的 mcp.config.json:
{
"performance": {
"cache": {
"maxSize": 500, // 500MB cache size
"ttl": 3600000, // 1 hour TTL
"maxItems": 50000, // 50k items max
"enablePersistence": true
},
"indexing": {
"enabled": true,
"rebuildInterval": 300000, // 5 minutes
"backgroundSync": true
},
"batch": {
"batchSize": 20,
"concurrency": 10,
"maxRetries": 3
},
"pool": {
"maxConnections": 50,
"acquireTimeout": 10000,
"idleTimeout": 60000
}
}
}缩放指南
| 缩放 | 页面 | 用户 | 缓存大小 | 预期性能 |
|---|---|---|---|---|
| 小型 | \50RPS | |||
| 中等 | \100 RPS | |||
| 大 | \200 RPS | |||
| 企业 | >1M | >500 | 8GB | >500 RPS |
🧪 测试
标准测试命令
Node.js测试
# Build the project
npm run build
# or
just build
# Run a simple test
npm run test:simple
# or
just test-simple
# Run an interactive test client
npm run test:interactive
# or
just test-interactive
# Run a query test
npm run test:query
# or
just test-query
# Run all tests
npm run test:all
# or
just test-all镍测试
# Simple test with Nix
nix run .#test
# or
just nix-test
# Interactive test with Nix
nix run .#interactive
# or
just nix-test-interactive
# Build with Nix
nix build
# or
just nix-build🐳 Docker测试(POC私有维基)
该项目包括一个全面的基于Docker的POC,用于测试私有wiki身份验证:
Docker POC命令
# Build POC Docker images (includes TypeScript compilation)
just docker-poc-build
# Build POC Docker images without cache (for fresh builds)
just docker-poc-build-no-cache
# Start POC containers (markdown server + MCP server)
just docker-poc-up
# Stop POC containers
just docker-poc-down
# Run comprehensive POC test suite
just docker-poc-test
# Individual POC tests
just test-auth-poc # Basic authentication tests
just test-auth-integration # Integration authentication tests
just test-poc-interactive # Interactive test client
just test-poc-monitor # Container health monitoring
just test-poc-menu # Interactive test menuDocker POC演示了什么:
- ✅ 私有Wiki身份验证:MCP服务器连接到受密码保护的wiki
- ✅ 容器化部署:这两个服务都在Docker容器中运行,并进行健康检查
- ✅ 身份验证方法:基本身份验证、令牌身份验证和自定义标头身份验证
- ✅ 集成测试:验证所有功能的全面测试套件
- ✅ 生产准备就绪:具有网络和服务发现的真实部署场景
🏗️ 建筑
- 📡 标准/JSON-RPC通信:轻量级、快速的通信协议
- 🧠 MCP服务器核心:中央请求处理程序和方法调度器
- 🔌 可扩展源:适用于不同wiki平台的可插拔系统
- 🔍 智能上下文检索:优化搜索和上下文管理
📚 文档
🔧 延伸
MCP Wiki服务器是为扩展而构建的:
- 在中添加新源
src/sources/并将其注册到MCPServer - 在中实施新的MCP方法
MCPServer根据需要 - 支持多种wiki格式:
- 降价 - 维基百科 - Gitbook - 汇流 - SharePoint - 自定义来源
👨💻 发展
# Enter development environment with Nix
nix develop
# or
just nix-shell
# Build with Nix
nix build
# or
just nix-build请参阅 Nix开发指南 了解更多详情。
📋 需求
- Node.js 14.x或更高版本
- 对于NixOS:已启用薄片
📄 许可证
麻省理工学院 -请随意使用、修改和分发此软件。
______________________________________________________________________
Made with ❤️ for developers who value their workflow
