Skip to content

Commit 89bc115

Browse files
committed
WIP
1 parent a7b93ad commit 89bc115

File tree

20 files changed

+2259
-2
lines changed

20 files changed

+2259
-2
lines changed

.gitignore

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,30 @@ Desktop.ini
152152

153153
# Repomix output
154154
repomix-output.txt
155-
repomix-output.xml
155+
repomix-output.xml
156+
157+
# Cursor
158+
.cursor/
159+
160+
# Added by Claude Task Master
161+
# Logs
162+
logs
163+
npm-debug.log*
164+
yarn-debug.log*
165+
yarn-error.log*
166+
dev-debug.log
167+
# Dependency directories
168+
node_modules/
169+
# Environment variables
170+
# Editor directories and files
171+
.idea
172+
.vscode
173+
*.suo
174+
*.ntvs*
175+
*.njsproj
176+
*.sln
177+
*.sw?
178+
# OS specific
179+
# Task files
180+
tasks.json
181+
tasks/

.taskmasterconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"models": {
3+
"main": {
4+
"provider": "anthropic",
5+
"modelId": "claude-3-7-sonnet-20250219",
6+
"maxTokens": 120000,
7+
"temperature": 0.2
8+
},
9+
"research": {
10+
"provider": "perplexity",
11+
"modelId": "sonar-pro",
12+
"maxTokens": 8700,
13+
"temperature": 0.1
14+
},
15+
"fallback": {
16+
"provider": "anthropic",
17+
"modelId": "claude-3-5-sonnet-20240620",
18+
"maxTokens": 8192,
19+
"temperature": 0.1
20+
}
21+
},
22+
"global": {
23+
"logLevel": "info",
24+
"debug": false,
25+
"defaultSubtasks": 5,
26+
"defaultPriority": "medium",
27+
"projectName": "Taskmaster",
28+
"ollamaBaseUrl": "http://localhost:11434/api",
29+
"azureOpenaiBaseUrl": "https://your-endpoint.openai.azure.com/",
30+
"userId": "1234567890"
31+
}
32+
}

README.md

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,152 @@
1-
# tadata-python-sdk
1+
# Tadata Python SDK
2+
3+
The Tadata Python SDK provides an easy-to-use interface for deploying Model Context Protocol (MCP) servers from OpenAPI specifications.
4+
5+
## Installation
6+
7+
```bash
8+
# Install with pip
9+
pip install tadata-sdk
10+
11+
# Or with uv (recommended)
12+
uv pip install tadata-sdk
13+
```
14+
15+
## Quickstart
16+
17+
Deploy a Model Context Protocol (MCP) server with your OpenAPI specification:
18+
19+
```python
20+
from tadata_sdk import deploy, OpenAPISpec
21+
22+
# Deploy from a dictionary
23+
result = deploy(
24+
openapi_spec={
25+
"openapi": "3.0.0",
26+
"info": {"title": "My API", "version": "1.0.0"},
27+
"paths": {"/hello": {"get": {"responses": {"200": {"description": "OK"}}}}},
28+
},
29+
api_key="your-tadata-api-key",
30+
name="My MCP Deployment", # Optional
31+
base_url="https://api.myservice.com", # Optional
32+
)
33+
34+
print(f"Deployed MCP server: {result.id}")
35+
print(f"Created at: {result.created_at}")
36+
```
37+
38+
## OpenAPI Specification Sources
39+
40+
The SDK supports multiple ways to provide your OpenAPI specification:
41+
42+
```python
43+
# From a file (JSON or YAML)
44+
result = deploy(
45+
openapi_spec_path="./openapi.json", # or .yaml
46+
api_key="your-tadata-api-key",
47+
)
48+
49+
# From a URL
50+
result = deploy(
51+
openapi_spec_url="https://example.com/openapi.json", # or .yaml
52+
api_key="your-tadata-api-key",
53+
)
54+
55+
# From a dictionary
56+
result = deploy(
57+
openapi_spec={
58+
"openapi": "3.0.0",
59+
"info": {"title": "My API", "version": "1.0.0"},
60+
"paths": {"/hello": {"get": {"responses": {"200": {"description": "OK"}}}}},
61+
},
62+
api_key="your-tadata-api-key",
63+
)
64+
65+
# From an OpenAPISpec object
66+
spec = OpenAPISpec.from_file("./openapi.json")
67+
result = deploy(
68+
openapi_spec=spec,
69+
api_key="your-tadata-api-key",
70+
)
71+
```
72+
73+
## Authentication Handling
74+
75+
You can configure how authentication is handled between the MCP server and your API:
76+
77+
```python
78+
result = deploy(
79+
openapi_spec_path="./openapi.json",
80+
api_key="your-tadata-api-key",
81+
auth_config={
82+
"pass_headers": ["authorization", "x-api-key"], # Headers to pass through
83+
"pass_query_params": ["api_key"], # Query parameters to pass through
84+
"pass_json_body_params": [], # JSON body parameters to extract
85+
"pass_form_data_params": [], # Form data parameters to extract
86+
}
87+
)
88+
```
89+
90+
## Error Handling
91+
92+
The SDK provides specific error classes for better error handling:
93+
94+
```python
95+
from tadata_sdk import deploy, SpecInvalidError, AuthError, ApiError, NetworkError
96+
97+
try:
98+
result = deploy(
99+
openapi_spec_path="./openapi.json",
100+
api_key="your-tadata-api-key",
101+
)
102+
print(f"Deployed MCP server: {result.id}")
103+
except SpecInvalidError as e:
104+
print(f"Invalid OpenAPI spec: {e}")
105+
print(f"Details: {e.details}")
106+
except AuthError as e:
107+
print(f"Authentication failed: {e}")
108+
except ApiError as e:
109+
print(f"API error: {e}, Status: {e.status_code}")
110+
except NetworkError as e:
111+
print(f"Network error: {e}")
112+
except Exception as e:
113+
print(f"Unexpected error: {e}")
114+
```
115+
116+
## Advanced Usage
117+
118+
### Custom Logging
119+
120+
You can provide your own logger implementation:
121+
122+
```python
123+
import logging
124+
from tadata_sdk import deploy
125+
126+
# Configure a custom logger
127+
logging.basicConfig(level=logging.DEBUG)
128+
logger = logging.getLogger("tadata-example")
129+
130+
# Use the custom logger
131+
result = deploy(
132+
openapi_spec_path="./openapi.json",
133+
api_key="your-tadata-api-key",
134+
logger=logger,
135+
)
136+
```
137+
138+
### Development Environment
139+
140+
For testing purposes, you can use the development environment:
141+
142+
```python
143+
result = deploy(
144+
openapi_spec_path="./openapi.json",
145+
api_key="your-tadata-api-key",
146+
dev=True, # Use development environment
147+
)
148+
```
149+
150+
## License
151+
152+
MIT

examples/deploy_mcp.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
5+
# Add the project root to the Python path if running from examples directory
6+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
7+
8+
import logging
9+
from typing import Dict, Any
10+
11+
from tadata_sdk import deploy
12+
13+
14+
# Sample simple OpenAPI spec
15+
SAMPLE_SPEC: Dict[str, Any] = {
16+
"openapi": "3.0.0",
17+
"info": {
18+
"title": "Sample API",
19+
"version": "1.0.0",
20+
"description": "A sample API specification for Tadata SDK example",
21+
},
22+
"paths": {
23+
"/hello": {
24+
"get": {
25+
"summary": "Say hello",
26+
"operationId": "sayHello",
27+
"responses": {
28+
"200": {
29+
"description": "A hello message",
30+
"content": {
31+
"application/json": {
32+
"schema": {
33+
"type": "object",
34+
"properties": {
35+
"message": {"type": "string"},
36+
},
37+
}
38+
}
39+
},
40+
}
41+
},
42+
}
43+
}
44+
},
45+
"servers": [{"url": "https://example.com/api"}],
46+
}
47+
48+
49+
def main() -> None:
50+
"""Run the example."""
51+
# Configure logging
52+
logging.basicConfig(level=logging.INFO)
53+
54+
# Get API key from environment variable
55+
api_key = os.environ.get("TADATA_API_KEY")
56+
if not api_key:
57+
print("Error: TADATA_API_KEY environment variable is required")
58+
sys.exit(1)
59+
60+
print("Deploying MCP server from OpenAPI spec...")
61+
62+
# Method 1: Using a dictionary directly
63+
result = deploy(
64+
openapi_spec=SAMPLE_SPEC,
65+
api_key=api_key,
66+
# Optional: specify a different base URL for the API
67+
base_url="https://my-actual-api.example.com/v1",
68+
name="Sample API Deployment",
69+
)
70+
71+
print("Successfully deployed MCP server!")
72+
print(f" ID: {result.id}")
73+
print(f" Created at: {result.created_at}")
74+
print(f" Updated: {result.updated}")
75+
76+
# Method 2: Using an OpenAPISpec object
77+
# spec = OpenAPISpec.from_dict(SAMPLE_SPEC)
78+
# result = deploy(openapi_spec=spec, api_key=api_key)
79+
80+
# Method 3: Loading from a file
81+
# result = deploy(openapi_spec_path="./openapi.json", api_key=api_key)
82+
83+
# Method 4: Loading from a URL
84+
# result = deploy(openapi_spec_url="https://example.com/openapi.json", api_key=api_key)
85+
86+
87+
if __name__ == "__main__":
88+
main()

0 commit comments

Comments
 (0)