定制 bluefly/mcp_registry 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bluefly/mcp_registry

Composer 安装命令:

composer require bluefly/mcp_registry

包简介

Registry and management system for Model Context Protocol (MCP) servers and resources

README 文档

README

Overview

This guide documents the integration of Model Context Protocol (MCP) servers into the LLM Platform, enabling connection to the broader MCP ecosystem for enhanced AI tools and capabilities.

Architecture

┌─────────────────────────────────────────────────────────┐
│                    LLM Platform                         │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  ┌──────────────┐     ┌─────────────────────┐         │
│  │   Drupal     │────▶│  MCP Integration   │         │
│  │   Modules    │     │     Module         │         │
│  └──────────────┘     └─────────────────────┘         │
│                              │                         │
└──────────────────────────────┼─────────────────────────┘
                               │
                    ┌──────────▼──────────┐
                    │   MCP Servers       │
                    ├──────────────────────┤
                    │ • LLM MCP (3100)    │
                    │ • Vector (3101)     │
                    │ • TDDAI (3102)      │
                    │ • API (3103)        │
                    └──────────────────────┘
                               │
                    ┌──────────▼──────────┐
                    │  External MCP Tools │
                    ├──────────────────────┤
                    │ • GitHub            │
                    │ • GitLab            │
                    │ • Filesystem        │
                    │ • Database          │
                    │ • Search            │
                    │ • Memory            │
                    └──────────────────────┘

Components

1. MCP Servers

LLM MCP Server (Port 3100)

  • Location: /common_npm/llm_mcp
  • Purpose: Main MCP server for LLM Platform operations
  • Features:
    • AI agent orchestration
    • Vector database integration
    • Marketplace connectivity
    • Tool discovery and management

Vector Server (Port 3101)

  • Purpose: Specialized vector operations and RAG
  • Features:
    • Qdrant integration
    • Semantic search
    • Embedding management
    • Document chunking

TDDAI Server (Port 3102)

  • Location: /common_npm/tddai
  • Purpose: Test-driven development AI assistance
  • Features:
    • Code generation
    • Test creation
    • Quality analysis
    • Refactoring suggestions

API Server (Port 3103)

  • Purpose: RESTful API for MCP operations
  • Features:
    • Tool execution endpoints
    • Server management
    • Health monitoring
    • Authentication

2. Drupal Integration Module

Module: mcp_integration Location: /web/modules/custom/mcp_integration

Services:

  • mcp_integration.client: Main client for MCP communication
  • mcp_integration.server_manager: Manages MCP server connections

Key Features:

  • Tool discovery
  • Tool execution
  • Connection testing
  • Configuration management

3. External MCP Tools

The platform can connect to various MCP servers from the ecosystem:

  • Filesystem: Access and manipulate local files
  • GitHub/GitLab: Repository management and CI/CD
  • PostgreSQL: Database operations
  • Brave Search: Web search capabilities
  • Memory: Persistent context storage

Installation & Setup

1. Prerequisites

# Ensure Node.js 20+ is installed
node --version

# Install required npm packages
cd ${LLM_COMMON_NPM_PATH:-../../common_npm}/llm_mcp
npm install

cd ${LLM_COMMON_NPM_PATH:-../../common_npm}/tddai
npm install

2. Build MCP Servers

# Build LLM MCP
cd ${LLM_COMMON_NPM_PATH:-../../common_npm}/llm_mcp
npm run build

# Build TDDAI
cd ${LLM_COMMON_NPM_PATH:-../../common_npm}/tddai
npm run build

3. Start MCP Servers

# Navigate to infrastructure directory
cd ${LLM_WORKSPACE_PATH:-../../../}llm-platform/infrastructure

# Start all MCP servers
./start-mcp-servers.sh

# Or start individually:
PORT=3100 npm run start:mcp     # LLM MCP Server
PORT=3101 npm run start:vector  # Vector Server
PORT=3102 npm run mcp:server    # TDDAI Server
PORT=3103 npm run start:api     # API Server

4. Enable Drupal Module

# Enable the MCP integration module
ddev drush en mcp_integration -y

# Clear cache
ddev drush cr

Configuration

MCP Server Configuration

Edit /llm-platform/infrastructure/mcp-config.json:

{
  "mcpServers": {
    "llm-platform": {
      "command": "node",
      "args": ["/path/to/llm_mcp/dist/index.js"],
      "env": {
        "MCP_SERVER_NAME": "llm-platform",
        "API_BASE_URL": "https://llm-platform.ddev.site"
      }
    }
  }
}

Drupal Configuration

Configure MCP servers in Drupal:

  1. Navigate to /admin/config/llm/mcp
  2. Add server endpoints:
    • LLM MCP: http://localhost:3100
    • Vector: http://localhost:3101
    • TDDAI: http://localhost:3102
    • API: http://localhost:3103

Usage

PHP (Drupal)

// Get MCP client service
$mcp_client = \Drupal::service('mcp_integration.client');

// Call a tool
$result = $mcp_client->callTool('llm-platform', 'search', [
  'query' => 'machine learning',
  'limit' => 10
]);

// Get available tools
$tools = $mcp_client->getAvailableTools('llm-platform');

// Test connection
$connected = $mcp_client->testConnection('llm-platform');

JavaScript/TypeScript

import { McpClient } from "@bluefly/llm-mcp";

const client = new McpClient({
  serverUrl: "http://localhost:3100",
});

// Call a tool
const result = await client.callTool("search", {
  query: "machine learning",
  limit: 10,
});

// Get available tools
const tools = await client.getTools();

CLI

# Using llmcli
llmcli mcp call llm-platform search --query "machine learning"

# Using tddai
tddai mcp tools list
tddai mcp call filesystem read --path "/path/to/file"

Testing

Test Connection

# Run connection test
node ${LLM_WORKSPACE_PATH:-../../../}llm-platform/infrastructure/test-mcp-connection.js

# Check server health
curl http://localhost:3100/health
curl http://localhost:3101/health
curl http://localhost:3102/health
curl http://localhost:3103/health

View Logs

# View server logs
tail -f /tmp/llm-mcp.log
tail -f /tmp/llm-mcp-vector.log
tail -f /tmp/tddai-mcp.log
tail -f /tmp/llm-mcp-api.log

Available MCP Tools

LLM Platform Tools

  • search: Semantic search across documents
  • embed: Generate embeddings for text
  • agent.create: Create AI agent instance
  • agent.execute: Execute agent task
  • workflow.run: Run automated workflow

TDDAI Tools

  • test.generate: Generate test cases
  • code.analyze: Analyze code quality
  • refactor.suggest: Get refactoring suggestions
  • coverage.check: Check test coverage

Vector Tools

  • vector.store: Store vectors in database
  • vector.search: Semantic similarity search
  • vector.delete: Remove vectors
  • collection.create: Create vector collection

Troubleshooting

Server Won't Start

# Check if port is already in use
lsof -i :3100

# Kill existing process
kill -9 $(lsof -t -i:3100)

# Restart server
./start-mcp-servers.sh

Connection Refused

  1. Ensure servers are running:
ps aux | grep "mcp"
  1. Check firewall settings
  2. Verify correct ports in configuration

Module Errors

# Clear Drupal cache
ddev drush cr

# Rebuild container
ddev restart

Security Considerations

  1. Authentication: Configure API keys for production
  2. Network: Use HTTPS in production environments
  3. Access Control: Limit MCP server access to trusted sources
  4. Secrets: Store sensitive data in environment variables

Performance Optimization

  1. Connection Pooling: Reuse HTTP connections
  2. Caching: Cache tool responses when appropriate
  3. Async Operations: Use background jobs for long-running tasks
  4. Rate Limiting: Implement rate limits for API endpoints

Extending MCP

Adding New Tools

  1. Create tool handler in MCP server:
export const myTool = {
  name: "my_tool",
  description: "My custom tool",
  parameters: {
    input: { type: "string", required: true },
  },
  handler: async (params) => {
    // Tool implementation
    return { result: "success" };
  },
};
  1. Register tool in server
  2. Restart MCP server
  3. Tool is now available to all clients

Resources

Support

For issues or questions:

  • Create issue in GitLab
  • Contact LLM Platform team
  • Check #mcp-integration Slack channel

bluefly/mcp_registry 适用场景与选型建议

bluefly/mcp_registry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 110 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 bluefly/mcp_registry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bluefly/mcp_registry 我们能提供哪些服务?
定制开发 / 二次开发

基于 bluefly/mcp_registry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 110
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-07-09