Laravel文档参考服务器

一个基于TypeScript的MCP服务器,为Laravel PHP框架提供官方文档参考信息,帮助AI助手直接访问Laravel文档和示例。

  • by benjibee
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 benjibee/laravel-mcp-server

使用说明

Laravel MCP服务器

Laravel PHP框架文档参考的MCP服务器

这是一个基于TypeScript的MCP服务器,为Laravel PHP框架文档提供参考信息。它实现了一个模型上下文协议(MCP)服务器,帮助AI助手直接从Laravel官方文档库访问Laravel文档和示例。

特性

工具

  • list_laravel_topics -获取所有可用Laravel文档主题的列表
  • get_laravel_topic_details -获取特定Laravel主题的详细信息
  • get_laravel_topic_examples -获取特定Laravel主题的使用示例
  • search_laravel_docs -按关键字搜索Laravel文档中的主题
  • list_laravel_categories -获取所有Laravel文档类别的列表

功能

此服务器从以下位置获取并缓存信息:

  • Laravel官方文档GitHub仓库(https://github.com/laravel/docs)
  • 为每个文档主题使用原始Markdown文件
  • 按类别组织主题(入门、基础、安全、数据库等)
  • 在本地缓存文档文件以避免重复下载

它提供结构化数据,包括:

  • 从Markdown文件中完成主题内容
  • 分类文档结构(入门、基础、前端、安全、数据库、Eloquent ORM、测试、深入挖掘、包、高级、杂项)
  • 带有语言检测的提取代码示例
  • 带有标题和锚点的章节内容
  • 智能描述提取
  • 常见主题的背景预加载
  • 脱机使用的持久文件缓存

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于自动重建的开发:

npm run watch

使用Augment

一旦你用Augment配置了Laravel MCP服务器,你就可以直接在VS Code环境中使用它来访问Laravel文档。以下是一些如何使用它的示例:

Laravel文档主题列表

你可以让Augment列出所有可用的Laravel文档主题:

What Laravel documentation topics are available?

或按类别列出主题:

What Laravel documentation topics are available in the "Database" category?
Show me all the topics in the "Eloquent ORM" category.

获取主题详细信息

您可以询问有关特定Laravel主题的详细信息:

Show me the documentation for Laravel installation.
Explain Laravel routing in detail.
I need help understanding Laravel's Eloquent relationships.

查找代码示例

您可以要求提供特定主题的代码示例:

Show me examples of Laravel routing.
Give me code examples for Eloquent models.
How do I implement middleware in Laravel? Show me some examples.

搜索文档

你可以在Laravel文档中搜索特定的概念:

Search Laravel documentation for "authentication".
Find information about queues in Laravel.
What does Laravel documentation say about caching?

结合编码任务

您可以将文档查询与编码任务结合起来:

I need to build a web application using Laravel. Show me the documentation and then help me implement it.
Help me create a Laravel API with authentication based on Laravel documentation.
I'm working on a Laravel project. Show me the Laravel documentation for database migrations and help me set up my database.

探索 Laravel 功能

你可以按类别探索Laravel的功能:

What are the main features available in Laravel?
Tell me about Laravel's Eloquent ORM capabilities.
What are the different ways to handle authentication in Laravel?

安装

增强配置

要在Visual Studio代码中与Augment一起使用,请执行以下操作:

  1. 如果还没有,请从VS Code市场安装Augment扩展。

  2. 如果您还没有MCP服务器,请为其创建一个新目录:

    mkdir -p ~/.augment/mcp-servers
    
  3. 将此存储库克隆到该目录中:

    git clone https://github.com/your-username/laravel-mcp-server.git ~/.augment/mcp-servers/laravel-mcp-server
    
  4. 安装依赖项并构建服务器:

    cd ~/.augment/mcp-servers/laravel-mcp-server
    npm install
    npm run build
    
  5. 通过将Augment添加到Augment配置中,配置Augment以使用此MCP服务器:

    打开VS代码设置(Mac上的Cmd+或Windows/Linux上的Ctrl+),搜索“增强”,找到“增强:MCP服务器”设置。点击“在settings.json中编辑”,添加以下内容:

    "augment.mcpServers": {
      "laravel-server": {
        "command": "node",
        "args": ["~/.augment/mcp-servers/laravel-mcp-server/build/index.js"]
      }
    }
    

    或者,您可以使用服务器的绝对路径:

    "augment.mcpServers": {
      "laravel-server": {
        "command": "node",
        "args": ["/absolute/path/to/laravel-mcp-server/build/index.js"]
      }
    }
    
  6. 重新启动VS Code以应用更改。

  7. 现在,您可以在PHP项目中使用Laravel文档工具和Augment!

Claude桌面配置

要与Claude Desktop一起使用,请添加服务器配置:

在MacOS上: ~/Library/Application Support/Claude/claude_desktop_config.json 在Windows上: %APPDATA%/Claude/claude_desktop_config.json

选项1:使用本地构建

{
  "mcpServers": {
    "laravel-server": {
      "command": "/path/to/laravel-mcp-server/build/index.js"
    }
  }
}

选项2:使用npx命令

{
  "mcpServers": {
    "laravel-server": {
      "command": "npx",
      "args": ["-y", "laravel-mcp-server"]
    }
  }
}

风帆配置

将此添加到您的 ./codeium/windsurf/model_config.json:

{
  "mcpServers": {
    "laravel-server": {
      "command": "npx",
      "args": ["-y", "laravel-mcp-server"]
    }
  }
}

光标配置

将此添加到您的 .cursor/mcp.json:

{
  "mcpServers": {
    "laravel-server": {
      "command": "npx",
      "args": ["-y", "laravel-mcp-server"]
    }
  }
}

调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。我们建议使用 MCP检查员,可作为包脚本使用:

npm run inspector

检查器将提供一个URL,用于访问浏览器中的调试工具。

故障排除

如果您遇到Laravel MCP服务器的问题,请尝试以下解决方案:

  1. 服务器没有响应:

    • 确保服务器已正确安装和构建
    • 检查配置中的路径是否正确
    • 尝试重新启动VS代码
    • 检查VS Code输出面板是否有任何错误消息(查看>输出,然后从下拉列表中选择“增强”)
  2. 服务器崩溃或超时:

    • 服务器包含常见Laravel主题的回退数据,因此即使无法连接到GitHub,它也应该仍然可以工作
    • 如果你在公司防火墙或代理之后,它可能会阻止GitHub API请求
    • 尝试手动运行服务器以查看任何错误输出: node /path/to/laravel-mcp-server/build/index.js
    • 服务器在本地缓存文档文件,因此它应该在第一次成功运行后脱机工作
  3. 数据不正确或缺失:

    • 服务器将数据缓存在内存中以获得更好的性能。如果需要新数据,请重新启动VS Code
    • 如果缺少特定主题,您可以手动将其添加到源代码中的回退数据中
    • 要强制刷新缓存的文档文件,请删除 cache 目录并重新启动服务器
  4. Augment找不到服务器:

    • 确保配置中的服务器名称完全匹配: laravel-server
    • 检查服务器的路径是否正确且可访问
    • 尝试使用绝对路径,而不是 ~ 在您的配置中
  5. 缓存问题:

    • 服务器将文档文件存储在 cache 构建目录旁边的目录
    • 如果缓存文件出现问题,可以删除缓存目录以强制重新下载
    • 确保运行服务器的进程对缓存目录具有写权限

贡献

欢迎为改进Laravel MCP服务器做出贡献!以下是您可以做出贡献的一些方式:

  1. 错误报告:如果你发现了一个bug,请创建一个问题,并提供详细的重现步骤。

  2. 功能请求:如果您对新功能或改进有想法,请创建一个问题来讨论它们。

  3. 文档:通过修复错误或添加示例来帮助改进文档。

  4. 代码贡献:提交bug修复或新功能的pull请求。

开发过程

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 进行更改
  4. 提交您的更改(git commit -m 'Add some amazing feature')
  5. 推到分支(git push origin feature/amazing-feature)
  6. 打开拉取请求

跟上Laravel文档

此MCP服务器旨在与最新的Laravel文档配合使用。随着Laravel的发展,服务器可能需要更新以支持新版本或文档结构的更改。

许可证

麻省理工学院