Skip to main content

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

Metadata

Release files for tuya-developer-agent-mcp-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tuya-developer-agent-mcp-sdk 0.1.0
File Size Uploaded Provenance
tuya_developer_agent_mcp_sdk-0.1.0.tar.gz 24.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tuya-developer-agent-mcp-sdk 0.1.0
File Interpreter ABI Platform
tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.2 kB

Release files / tuya_developer_agent_mcp_sdk-0.1.0.tar.gz

Download URL tuya_developer_agent_mcp_sdk-0.1.0.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
18b7907eb097b598e8469cfac7516466f58534472aeafa2c987554ee291a9846
BLAKE2b-256 checksum
How to use checksums
8169eda7999f73095a7870c426d75bc6cbce272bf6553511da36d511cb4e54d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl

Download URL tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e21ac31b5284713b01e17ebead22b7ebb75693254bf5864bd25c0468e7bfa1d
BLAKE2b-256 checksum
How to use checksums
5762d042a1ad9c6763ef3a41ed795f8867cfa28e07aaf8f6252da152ef8b3577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for tuya-developer-agent-mcp-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page