涂鸦智能体平台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
- Parameter Description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tuya_developer_agent_mcp_sdk-0.1.0.tar.gz.
File metadata
- Download URL: tuya_developer_agent_mcp_sdk-0.1.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18b7907eb097b598e8469cfac7516466f58534472aeafa2c987554ee291a9846
|
|
| MD5 |
637213220dbe7d2c0e45354c2e9aadf8
|
|
| BLAKE2b-256 |
8169eda7999f73095a7870c426d75bc6cbce272bf6553511da36d511cb4e54d1
|
File details
Details for the file tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tuya_developer_agent_mcp_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e21ac31b5284713b01e17ebead22b7ebb75693254bf5864bd25c0468e7bfa1d
|
|
| MD5 |
9c54a1b634a4fb3021047e3360b1cf4d
|
|
| BLAKE2b-256 |
5762d042a1ad9c6763ef3a41ed795f8867cfa28e07aaf8f6252da152ef8b3577
|