Skip to content

ACNet-AI/mcp-factory-platform-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mcp-factory-platform-server

MCP Factory Platform Server - AI Agent interface layer for platform management functions

Converts the mcp-factory-platform backend REST API into MCP tools, enabling AI Agents (such as Claude) to manage users, wallets, billing and other platform functions through natural language conversation.

🌟 Features

πŸ” Authentication Management (6 tools)

  • get_oauth_login_url() - Get OAuth login URL
  • explain_authentication() - Detailed authentication configuration instructions
  • create_api_key() - Create new API Key ⭐ NEW
  • list_api_keys() - List all API Keys ⭐ NEW
  • delete_api_key() - Delete API Key ⭐ NEW
  • get_api_key_stats() - Get API Key usage statistics ⭐ NEW

πŸ‘€ User Management (4 tools)

  • get_user_profile() - Get user profile
  • update_user_profile() - Update user profile
  • get_user_account() - Get account summary
  • get_user_analytics() - User revenue analytics

πŸ–₯️ MCP Service Management (5 tools) ⭐ NEW

  • register_mcp_service() - Register new MCP service ⭐ NEW
  • list_my_services() - List all my services ⭐ NEW
  • update_mcp_service() - Update service information ⭐ NEW
  • delete_mcp_service() - Delete service ⭐ NEW
  • get_service_revenue() - View service revenue statistics ⭐ NEW

πŸ’° Wallet Management (5 tools)

  • get_consumer_wallet() - Get consumer wallet details
  • get_provider_wallet() - Get provider wallet details
  • create_charge() - Create charge order
  • transfer_credits() - Transfer credits between users
  • get_transactions() - Get transaction records

πŸ’Έ Withdrawal Management (3 tools) ⭐ NEW

  • request_withdrawal() - Request withdrawal ⭐ NEW
  • list_withdrawals() - List withdrawal records ⭐ NEW
  • get_withdrawal_detail() - View withdrawal details ⭐ NEW

πŸ“Š Billing Management (5 tools)

  • consume_service() - Consume service and bill
  • list_services() - List available MCP services
  • get_service_endpoint() - Get service endpoint details
  • check_server_balance() - Check server balance
  • get_server_analytics() - Get server usage analytics

πŸ”§ Platform Tools (1 tool)

  • test_platform_connection() - Test platform connection

Total: 28 MCP Tools ✨ Complete bilateral market closed loop!

πŸš€ Quick Start

Prerequisites

Step 1: OAuth Login and Get API Key

  1. Visit login page

    https://mcp-factory-beta.up.railway.app/auth/login
    
  2. Authorize with GitHub account

    • Automatically receive 1000 Beta credits after authorization
  3. Generate API Key

  4. Copy generated API Key

    • Format: mcp_key_xxxxxxxxxxxxxxxxx

Step 2: Configure Environment Variables

# 1. Copy environment configuration template
cp env.example .env

# 2. Edit .env file
nano .env

Add the following content:

# Platform backend address (production)
PLATFORM_API_BASE=https://mcp-factory-beta.up.railway.app

# API authentication key (obtained from platform)
PLATFORM_API_KEY=mcp_key_your_api_key_here

# API timeout
API_TIMEOUT=30.0

Step 3: Install Dependencies and Start

# Install dependencies
uv sync

# Test server
uv run python server.py

πŸ“‹ Cursor/Claude Desktop Configuration

Cursor Configuration

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "mcp-factory-platform-server": {
      "command": "/absolute/path/to/project/.venv/bin/python",
      "args": ["/absolute/path/to/project/server.py"],
      "cwd": "/absolute/path/to/mcp-factory-platform-server"
    }
  }
}

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-factory-platform-server": {
      "command": "uv",
      "args": ["run", "python", "server.py"],
      "cwd": "/path/to/mcp-factory-platform-server"
    }
  }
}

πŸ’‘ Usage Examples

Authentication and Connection Test

You: "Test platform connection"
Claude: 
βœ… Platform connection test successful
Health status: healthy
Service: mcp-factory-platform-foundation-early-access
Version: 0.9.0

User Profile Query

You: "Get my user profile"
Claude: Calling get_user_profile() ...

Wallet Balance Query

You: "Check my wallet balance"
Claude: Calling get_consumer_wallet() and get_provider_wallet() ...

Service List

You: "What MCP services are available"
Claude: Calling list_services() ...

πŸ—οΈ Project Structure

mcp-factory-platform-server/
β”œβ”€β”€ Dockerfile                    # Docker image configuration
β”œβ”€β”€ .dockerignore                 # Docker build exclusions
β”œβ”€β”€ docker-compose.yml            # Docker Compose orchestration
β”œβ”€β”€ config.yaml                   # Server configuration
β”œβ”€β”€ pyproject.toml                # Python project configuration
β”œβ”€β”€ server.py                     # Server entry file
β”œβ”€β”€ .env                          # Environment configuration (need to create)
β”œβ”€β”€ env.example                   # Environment configuration example
β”œβ”€β”€ README.md                     # This document
β”œβ”€β”€ CHANGELOG.md                  # Version changelog
β”œβ”€β”€ tools/                        # Tools implementation directory
β”‚   β”œβ”€β”€ auth_management.py        # Authentication management tools (2)
β”‚   β”œβ”€β”€ api_key_management.py     # API Key management tools (4)
β”‚   β”œβ”€β”€ user_management.py        # User management tools (4)
β”‚   β”œβ”€β”€ service_management.py     # MCP service management tools (5)
β”‚   β”œβ”€β”€ wallet_management.py      # Wallet management tools (5)
β”‚   β”œβ”€β”€ withdrawal_management.py  # Withdrawal management tools (3)
β”‚   β”œβ”€β”€ billing_management.py     # Billing management tools (5)
β”‚   └── platform_api_adapter.py   # Platform API adapter
β”œβ”€β”€ resources/                    # Resources implementation directory
└── prompts/                      # Prompt template directory

πŸ”§ Development

Adding New Tools

  1. Create a new file or edit existing file in tools/ directory
  2. Define tools using @server.tool() decorator
  3. Call platform API using httpx
  4. Add Authorization header for authentication

Example:

import httpx
import os

PLATFORM_API_BASE = os.getenv("PLATFORM_API_BASE", "http://localhost:8001")
PLATFORM_API_KEY = os.getenv("PLATFORM_API_KEY", "")

def _get_headers() -> dict:
    headers = {"Content-Type": "application/json"}
    if PLATFORM_API_KEY:
        headers["Authorization"] = PLATFORM_API_KEY
    return headers

async def my_new_tool(param: str) -> str:
    """Tool description"""
    async with httpx.AsyncClient(timeout=30.0) as client:
        response = await client.get(
            f"{PLATFORM_API_BASE}/api/endpoint",
            headers=_get_headers()
        )
        if response.status_code == 200:
            return f"Success: {response.json()}"
        return f"Failed: HTTP {response.status_code}"

Code Quality Check

# Ruff check
uv run ruff check .

# Auto-fix
uv run ruff check --fix .

# Format
uv run ruff format .

🐳 Docker Deployment

Docker Compose (Recommended)

# Build and start
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Docker Direct Run

# Build image
docker build -t mcp-factory-platform-server .

# Run container
docker run -d \
  --name mcp-platform-server \
  --env-file .env \
  mcp-factory-platform-server

πŸ” Authentication Instructions

OAuth Flow

  1. User visits /auth/login in browser
  2. Redirects to GitHub OAuth authorization page
  3. After user authorization, platform creates account and grants 1000 Beta credits
  4. User generates API Key on platform management page

API Key Usage

All MCP tools require API Key authentication:

  • Configure PLATFORM_API_KEY in .env file
  • API Key format: mcp_key_xxx
  • Restart MCP server to take effect

Beta Version Limitations

  • βœ… Available: All query and read functions
  • βœ… Available: Use platform's 1000 complimentary credits
  • ⚠️ Limited: Recharge function (not available in Beta)
  • ⚠️ Limited: Withdrawal function (not available in Beta)

πŸ“š Related Resources

πŸ†˜ Troubleshooting

Issue: Tools show "API Key not configured"

Solution:

  1. Ensure .env file is created
  2. Check if PLATFORM_API_KEY is correctly filled in
  3. Restart MCP server

Issue: Connection failed HTTP 502

Solution:

  1. Check if PLATFORM_API_BASE is correct
  2. Confirm platform backend is running
  3. Check network connection

Issue: All requests return 403

Solution:

  1. API Key may have expired or been revoked
  2. Regenerate API Key
  3. Update .env file and restart

Getting Help

Use MCP tools to view help:

  • explain_authentication() - Detailed authentication instructions
  • test_platform_connection() - Test connection
  • platform_status() - View platform status

πŸ“„ License

MIT License

πŸ“ Changelog

See CHANGELOG.md for version history.


Version: 1.3.0
Last Updated: 2025-10-18
Author: MCP Factory Team

✨ v1.3.0 Feature Highlights

Complete Bilateral Market Support

Now mcp-factory-platform-server supports complete bilateral market business processes:

Service Provider Workflow:

Register Service β†’ Set Pricing β†’ Earn Revenue β†’ Request Withdrawal

Service Consumer Workflow:

Browse Services β†’ Recharge Wallet β†’ Consume Services β†’ View Transactions

Core New Features

  1. πŸ”‘ Self-service API Key Management - No need to depend on web pages, AI Agent can directly create and manage API Keys
  2. πŸ–₯️ MCP Service Registration - Service providers can register and manage their own MCP services through AI Agent
  3. πŸ’Έ Withdrawal Function - Service providers can withdraw earnings to bank account/Alipay/WeChat

These features complete the platform's core business loop, making mcp-factory-platform a true bilateral market platform!

About

MCP Factory Platform Server - Agent interface for platform management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •