LLM代码生成服务

一个基于MCP服务器的LLM服务,提供代码生成、文档生成和问题解答功能,适用于开发效率提升和自动化编程场景。

  • by sammcj
  • JavaScript
  • 本地部署
  • 81 星标
  • 更新于
在 GitHub 查看 sammcj/mcp-llm

使用说明

MCP LLM

使用LlamaIndexTS库提供对LLM访问的MCP服务器。

特性

此MCP服务器提供以下工具:

  • generate_code:根据描述生成代码
  • generate_code_to_file:生成代码并将其直接写入特定行号的文件
  • generate_documentation:为代码生成文档
  • ask_question:向法学硕士提问

安装

通过Smithery安装

通过以下方式自动安装Claude Desktop的LLM服务器 史密瑟里:

npx -y @smithery/cli install @sammcj/mcp-llm --client claude

从源代码手动安装

  1. 克隆存储库
  2. 安装依赖项:
npm install
  1. 构建项目:
npm run build
  1. 更新您的MCP配置

使用示例脚本

该存储库包含一个示例脚本,演示如何以编程方式使用MCP服务器:

node examples/use-mcp-server.js

此脚本启动MCP服务器,并使用curl命令向其发送请求。

例子

生成代码

{
  "description": "Create a function that calculates the factorial of a number",
  "language": "JavaScript"
}

生成代码以归档

{
  "description": "Create a function that calculates the factorial of a number",
  "language": "JavaScript",
  "filePath": "/path/to/factorial.js",
  "lineNumber": 10,
  "replaceLines": 0
}

这 generate_code_to_file 该工具支持相对和绝对文件路径。如果提供了相对路径,它将相对于MCP服务器的当前工作目录进行解析。

生成文档

{
  "code": "function factorial(n) {\n  if (n <= 1) return 1;\n  return n * factorial(n - 1);\n}",
  "language": "JavaScript",
  "format": "JSDoc"
}

提问

{
  "question": "What is the difference between var, let, and const in JavaScript?",
  "context": "I'm a beginner learning JavaScript and confused about variable declarations."
}

许可证