yourname 4684a459bf fix: 修复 companyCreateTool 类型安全问题 3 недель назад
..
src 4684a459bf fix: 修复 companyCreateTool 类型安全问题 3 недель назад
README.md 2bd3ed3c1d feat: 添加 Admin MCP Server 和安装配置技能 3 недель назад
package.json 2bd3ed3c1d feat: 添加 Admin MCP Server 和安装配置技能 3 недель назад
tsconfig.json 2bd3ed3c1d feat: 添加 Admin MCP Server 和安装配置技能 3 недель назад

README.md

Admin MCP Server

MCP (Model Context Protocol) server for admin backend API integration. This server enables AI agents to interact with the admin system through well-defined tools.

Features

  • Authentication: Login/logout and user session management
  • User Management: CRUD operations for users
  • Role Management: CRUD operations for roles
  • System Configuration: CRUD operations for system configs
  • Order Management: List and view orders
  • Streamable HTTP Transport: Modern, stateless HTTP transport for remote access

Installation

cd packages/admin-mcp-server
pnpm install

Configuration

Set environment variables:

# API backend URL (default: http://localhost:8080)
export API_BASE_URL="http://localhost:8080"

# MCP server port (default: 3000)
export PORT="3000"

Usage

Development

pnpm run dev

Production

# Build
pnpm run build

# Start
pnpm start

Health Check

curl http://localhost:3000/health

MCP Tools

Authentication

  • admin_login - Authenticate with username and password
  • admin_logout - Logout and clear session
  • admin_get_current_user - Get current authenticated user info

User Management

  • admin_list_users - List users with pagination and filtering
  • admin_get_user - Get user by ID
  • admin_create_user - Create a new user
  • admin_update_user - Update existing user
  • admin_delete_user - Delete a user

Role Management

  • admin_list_roles - List roles with pagination
  • admin_get_role - Get role by ID
  • admin_create_role - Create a new role
  • admin_update_role - Update existing role
  • admin_delete_role - Delete a role

System Configuration

  • admin_list_system_configs - List system configurations
  • admin_get_system_config - Get config by ID
  • admin_create_system_config - Create a new config
  • admin_update_system_config - Update existing config
  • admin_delete_system_config - Delete a config

Order Management

  • admin_list_orders - List orders with pagination
  • admin_get_order - Get order by ID

MCP Connection

To connect to this MCP server, use:

http://localhost:3000/mcp

Example Usage

Using MCP Inspector

npx @modelcontextprotocol/inspector http://localhost:3000/mcp

Claude Desktop Configuration

Add to your Claude Desktop config:

{
  "mcpServers": {
    "admin": {
      "url": "http://localhost:3000/mcp",
      "transport": "streamable_http"
    }
  }
}

API Endpoints

The MCP server connects to the following backend API endpoints:

  • /api/auth/login - Admin login
  • /api/auth/me - Get current user
  • /api/users - User management
  • /api/roles - Role management
  • /api/system-configs - System configuration
  • /api/orders - Order management

Project Structure

admin-mcp-server/
├── src/
│   ├── index.ts          # Main entry point
│   ├── constants.ts      # Constants and enums
│   ├── types.ts          # Type definitions
│   ├── schemas/          # Zod validation schemas
│   ├── services/         # API client service
│   └── tools/            # MCP tool implementations
├── dist/                 # Built JavaScript files
├── package.json
├── tsconfig.json
└── README.md

License

MIT