Skip to content

Commit 1fb054c

Browse files
authored
Replace requests with httpx (#25)
* use client instead of requests * refactor * remove requests as a dependency * add storrage tools to mcp
1 parent 28044db commit 1fb054c

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

python/thirdweb-ai/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ dependencies = [
2020
"jsonref>=1.1.0,<2",
2121
"httpx>=0.28.1,<0.29",
2222
"aiohttp>=3.11.14",
23-
"requests>=2.32.3",
2423
]
2524

2625
[project.optional-dependencies]

python/thirdweb-ai/src/thirdweb_ai/services/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, base_url: str, secret_key: str, httpx_client: httpx.Client |
1212
self.base_url = base_url
1313
self.secret_key = secret_key
1414
self.client = (
15-
httpx_client if httpx_client else httpx.Client(timeout=120.0, transport=httpx.HTTPTransport(retries=5))
15+
httpx_client or httpx.Client(timeout=120.0, transport=httpx.HTTPTransport(retries=5))
1616
)
1717

1818
def _make_headers(self):

python/thirdweb-ai/src/thirdweb_ai/services/storage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pathlib import Path
88
from typing import Annotated, Any
99

10-
import requests
1110
from pydantic import BaseModel
1211

1312
from thirdweb_ai.services.service import Service
@@ -75,10 +74,9 @@ def _get_file(self, path: str, params: dict[str, Any] | None = None, headers: di
7574
def _post_file(self, url: str, files: dict[str, Any]) -> dict[str, Any]:
7675
"""Post files to a URL with proper authorization headers."""
7776
headers = self._make_headers()
78-
# Remove the Content-Type as requests will set it correctly for multipart/form-data
7977
headers.pop("Content-Type", None)
8078

81-
response = requests.post(url, files=files, headers=headers)
79+
response = self.client.post(url, files=files, headers=headers)
8280
response.raise_for_status()
8381
return response.json()
8482

python/thirdweb-ai/uv.lock

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/thirdweb-mcp/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "thirdweb-mcp"
3-
version = "0.1.12"
3+
version = "0.1.13"
44
description = "thirdweb MCP"
55
authors = [{ name = "thirdweb", email = "[email protected]" }]
66
requires-python = "~=3.10"

python/thirdweb-mcp/src/mcp.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import os
22

33
import click
4-
from mcp.server.fastmcp import FastMCP
5-
from thirdweb_ai import Engine, Insight, Nebula
4+
from thirdweb_ai import Engine, Insight, Nebula, Storage
65
from thirdweb_ai.adapters.mcp import add_fastmcp_tools
76

7+
from mcp.server.fastmcp import FastMCP
8+
89

910
@click.command()
1011
@click.option(
@@ -25,7 +26,7 @@
2526
"--secret-key",
2627
type=str,
2728
default=lambda: os.getenv("THIRDWEB_SECRET_KEY"),
28-
help="Your thirdweb API secret key for authentication. Required for nebula and insight services. Can be obtained from the thirdweb dashboard. Falls back to THIRDWEB_SECRET_KEY environment variable if not specified.",
29+
help="Your thirdweb API secret key for authentication. Required for nebula, insight, and storage services. Can be obtained from the thirdweb dashboard. Falls back to THIRDWEB_SECRET_KEY environment variable if not specified.",
2930
)
3031
@click.option(
3132
"--chain-id",
@@ -69,7 +70,7 @@ def main(
6970
# determine which services to enable based on the provided options
7071
services = []
7172
if secret_key:
72-
services.extend(["nebula", "insight"])
73+
services.extend(["nebula", "insight", "storage"])
7374

7475
if engine_url and engine_auth_jwt:
7576
services.append("engine")
@@ -88,6 +89,10 @@ def main(
8889
insight = Insight(secret_key=secret_key, chain_id=chain_ids)
8990
add_fastmcp_tools(mcp, insight.get_tools())
9091

92+
if "storage" in services:
93+
storage = Storage(secret_key=secret_key)
94+
add_fastmcp_tools(mcp, storage.get_tools())
95+
9196
if "engine" in services:
9297
engine = Engine(
9398
engine_url=engine_url,

0 commit comments

Comments
 (0)