Skip to main content

涂鸦智能体平台MCP接入sdk

Project description

Custom MCP SDK

1. Overview

1.1. SDK Usage

  • Init SDK Config

Before initialization, you need to obtain AccessId, AccessSecret, and Endpoint from the developer platform.

from mcp_sdk import create_mcpsdk

# Create MCP SDK with configuration
mcpsdk = await create_mcpsdk(
    # Set custom MCP server endpoint
    custom_mcp_server_endpoint="http://localhost:8765/mcp",
    # Set Access ID, Access secret and Endpoint
    endpoint="your-endpoint",
    access_id="your-access-id", 
    access_secret="your-access-secret"
)
  • Running SDK
import asyncio

async def main():
    async with mcpsdk:
        print("🚀 MCP SDK connected successfully!")
        await mcpsdk.start_background()
        
        # Keep running
        while mcpsdk.is_running:
            await asyncio.sleep(10)

if __name__ == "__main__":
    asyncio.run(main())

1.2. Architecture Diagram

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   Your App      │───▶│    MCP SDK       │───▶│  MCP Gateway    │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                              │
                              ▼
                       ┌──────────────────┐
                       │   MCP Server     │
                       └──────────────────┘

2. Quick Start

Prerequisites:

The machine has Python 3.10+ environment for Python development, and pip >= 21.3.

  • Checkout source code

    git clone https://github.com/tuya/tuya-mcp-sdk.git
    
    cd mcp-python
    
  • Run SDK Example

    # Create virtual environment
    python -m venv .venv 
    # or `python3 -m venv .venv`
    
    # Activate virtual environment
    source .venv/bin/activate  # Linux/Mac
    
    # Install development dependencies
    pip install -e ".[dev]"
    
    # Run with custom parameters
    python -m examples all --endpoint your-endpoint --access-id your-access-id --access-secret your-access-secret --custom-mcp-server-endpoint http://localhost:8765/mcp
    
    • Parameter Description
      • endpoint: Tuya developer platform MCP endpoint
      • access-id: Tuya developer platform MCP access id
      • access-secret: Tuya developer platform MCP access secret
      • custom-mcp-server-endpoint: Address of custom MCP Server Endpoint declared in SDK; current demo includes an MCP Server example http://localhost:8765/mcp

3. Develop Custom MCP Server

Developers develop custom MCP Servers based on business to provide capabilities for their devices.

3.1. Develop By FastMCP

  • Create a New MCP Server
from fastmcp import FastMCP

mcp_server = FastMCP("Demo 🚀")
  • Create a Tool
@mcp_server.tool()
def hello_world(name: str) -> str:
    """Say hello to someone
    
    Args:
        name: Name of the person to greet
    """
    return f"Hello, {name}!"

3.2. Run MCP Server

from fastmcp import FastMCP

def main():
    # Create a new MCP server
    mcp_server = FastMCP("Demo 🚀")

    # Add tool
    @mcp_server.tool()
    def hello_world(name: str) -> str:
        """Say hello to someone
        
        Args:
            name: Name of the person to greet
        """
        return f"Hello, {name}!"

    # Start the server
    mcp_server.run()

if __name__ == "__main__":
    main()

3.3. Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuya_developer_agent_mcp_sdk-0.1.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file tuya_developer_agent_mcp_sdk-0.1.0.tar.gz.

File metadata

File hashes

Hashes for tuya_developer_agent_mcp_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18b7907eb097b598e8469cfac7516466f58534472aeafa2c987554ee291a9846
MD5 637213220dbe7d2c0e45354c2e9aadf8
BLAKE2b-256 8169eda7999f73095a7870c426d75bc6cbce272bf6553511da36d511cb4e54d1

See more details on using hashes here.

File details

Details for the file tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e21ac31b5284713b01e17ebead22b7ebb75693254bf5864bd25c0468e7bfa1d
MD5 9c54a1b634a4fb3021047e3360b1cf4d
BLAKE2b-256 5762d042a1ad9c6763ef3a41ed795f8867cfa28e07aaf8f6252da152ef8b3577

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page