sunfield-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sunfield-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Model Context Protocol (MCP) server for Sunfield — hosted & stdio headless Blender sandboxes and Cycles OptiX rendering for AI agents
|
|
5
|
+
Project-URL: Homepage, https://sunfield.dev/mcp-server
|
|
6
|
+
Project-URL: Repository, https://github.com/Strange-Metal/sunfield-sdk
|
|
7
|
+
Project-URL: Documentation, https://sunfield.dev/skill.md
|
|
8
|
+
Project-URL: Remote MCP Endpoint, https://sunfield.dev/mcp
|
|
9
|
+
Project-URL: Server Card, https://sunfield.dev/.well-known/mcp/server-card.json
|
|
10
|
+
Author-email: "Strange Metal, Inc." <contact@strangemetal.org>
|
|
11
|
+
License: MIT
|
|
12
|
+
Keywords: 3d,ai-agents,blender,blender-mcp,claude-code,cursor,cycles,headless-blender,mcp,model-context-protocol,optix
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Rendering
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: httpx>=0.27.0
|
|
22
|
+
Requires-Dist: mcp>=1.2.0
|
|
23
|
+
Requires-Dist: pydantic>=2.9.0
|
|
24
|
+
Requires-Dist: sunfield>=0.1.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8.3.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.7.0; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# `sunfield-mcp` — Official Sunfield MCP Server
|
|
32
|
+
|
|
33
|
+
Give Claude Code, Cursor, Windsurf, Codex, or any MCP-compatible agent isolated headless Blender 4.5 GPU sandboxes with visual feedback (`ImageContent` + spatial JSON) and elastic Cycles OptiX burst rendering.
|
|
34
|
+
|
|
35
|
+
## Recommended: Zero-Install Hosted Remote MCP (`https://sunfield.dev/mcp`)
|
|
36
|
+
|
|
37
|
+
No local Python or Blender installation needed — Sunfield hosts Streamable HTTP Remote MCP with 1-click OAuth 2.1 (`$1.00` free trial, no credit card) and all 15 tools (including CC0 asset contact sheets and in-chat Stripe top-ups via `sunfield_topup`):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
claude mcp add --transport http sunfield https://sunfield.dev/mcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Local `stdio` Server (`sunfield-mcp`)
|
|
44
|
+
|
|
45
|
+
If your MCP client only supports local `stdio` servers:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"sunfield": {
|
|
51
|
+
"command": "uvx",
|
|
52
|
+
"args": ["sunfield-mcp"],
|
|
53
|
+
"env": {
|
|
54
|
+
"SUNFIELD_API_KEY": "sunfield_sk_...",
|
|
55
|
+
"SUNFIELD_BASE_URL": "https://sunfield.dev"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Get a free `$1.00` trial API key at [sunfield.dev/start](https://sunfield.dev/start). See [sunfield.dev/mcp-server](https://sunfield.dev/mcp-server) for the full 15-tool Remote MCP reference and [sunfield.dev/pricing](https://sunfield.dev/pricing) for rates and capacity plans.
|
|
63
|
+
|
|
64
|
+
## Local `stdio` Tools
|
|
65
|
+
|
|
66
|
+
| Tool | Description |
|
|
67
|
+
| :--- | :--- |
|
|
68
|
+
| `sunfield_balance` | Check credit balance (USD) & recent ledger entries |
|
|
69
|
+
| `sunfield_create_session` | Claim a warm headless Blender sandbox (`studio`, `empty`, `default`) |
|
|
70
|
+
| `sunfield_list_sessions` | List active & recent sessions |
|
|
71
|
+
| `sunfield_exec` | Execute `bpy` code with `tmpfs` crash auto-recovery & `SceneDiff` |
|
|
72
|
+
| `sunfield_inspect` | Multi-view EEVEE preview returning **native MCP `ImageContent` PNGs + spatial telemetry JSON** (bounds, framing, BVH collisions, floating objects) |
|
|
73
|
+
| `sunfield_fork` | Branch scene state into N parallel child sessions |
|
|
74
|
+
| `sunfield_render` | Burst-render Cycles OptiX frames with pre-flight cost probe & `max_cost_usd` cap |
|
|
75
|
+
| `sunfield_close_session` | Close session & settle exact active GPU-seconds |
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# `sunfield-mcp` — Official Sunfield MCP Server
|
|
2
|
+
|
|
3
|
+
Give Claude Code, Cursor, Windsurf, Codex, or any MCP-compatible agent isolated headless Blender 4.5 GPU sandboxes with visual feedback (`ImageContent` + spatial JSON) and elastic Cycles OptiX burst rendering.
|
|
4
|
+
|
|
5
|
+
## Recommended: Zero-Install Hosted Remote MCP (`https://sunfield.dev/mcp`)
|
|
6
|
+
|
|
7
|
+
No local Python or Blender installation needed — Sunfield hosts Streamable HTTP Remote MCP with 1-click OAuth 2.1 (`$1.00` free trial, no credit card) and all 15 tools (including CC0 asset contact sheets and in-chat Stripe top-ups via `sunfield_topup`):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
claude mcp add --transport http sunfield https://sunfield.dev/mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Local `stdio` Server (`sunfield-mcp`)
|
|
14
|
+
|
|
15
|
+
If your MCP client only supports local `stdio` servers:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"sunfield": {
|
|
21
|
+
"command": "uvx",
|
|
22
|
+
"args": ["sunfield-mcp"],
|
|
23
|
+
"env": {
|
|
24
|
+
"SUNFIELD_API_KEY": "sunfield_sk_...",
|
|
25
|
+
"SUNFIELD_BASE_URL": "https://sunfield.dev"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Get a free `$1.00` trial API key at [sunfield.dev/start](https://sunfield.dev/start). See [sunfield.dev/mcp-server](https://sunfield.dev/mcp-server) for the full 15-tool Remote MCP reference and [sunfield.dev/pricing](https://sunfield.dev/pricing) for rates and capacity plans.
|
|
33
|
+
|
|
34
|
+
## Local `stdio` Tools
|
|
35
|
+
|
|
36
|
+
| Tool | Description |
|
|
37
|
+
| :--- | :--- |
|
|
38
|
+
| `sunfield_balance` | Check credit balance (USD) & recent ledger entries |
|
|
39
|
+
| `sunfield_create_session` | Claim a warm headless Blender sandbox (`studio`, `empty`, `default`) |
|
|
40
|
+
| `sunfield_list_sessions` | List active & recent sessions |
|
|
41
|
+
| `sunfield_exec` | Execute `bpy` code with `tmpfs` crash auto-recovery & `SceneDiff` |
|
|
42
|
+
| `sunfield_inspect` | Multi-view EEVEE preview returning **native MCP `ImageContent` PNGs + spatial telemetry JSON** (bounds, framing, BVH collisions, floating objects) |
|
|
43
|
+
| `sunfield_fork` | Branch scene state into N parallel child sessions |
|
|
44
|
+
| `sunfield_render` | Burst-render Cycles OptiX frames with pre-flight cost probe & `max_cost_usd` cap |
|
|
45
|
+
| `sunfield_close_session` | Close session & settle exact active GPU-seconds |
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sunfield-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Model Context Protocol (MCP) server for Sunfield — hosted & stdio headless Blender sandboxes and Cycles OptiX rendering for AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Strange Metal, Inc.", email = "contact@strangemetal.org"}]
|
|
13
|
+
keywords = [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"blender",
|
|
17
|
+
"blender-mcp",
|
|
18
|
+
"headless-blender",
|
|
19
|
+
"cycles",
|
|
20
|
+
"optix",
|
|
21
|
+
"3d",
|
|
22
|
+
"ai-agents",
|
|
23
|
+
"claude-code",
|
|
24
|
+
"cursor",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Topic :: Multimedia :: Graphics :: 3D Rendering",
|
|
33
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"sunfield>=0.1.0",
|
|
37
|
+
"mcp>=1.2.0",
|
|
38
|
+
"httpx>=0.27.0",
|
|
39
|
+
"pydantic>=2.9.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://sunfield.dev/mcp-server"
|
|
44
|
+
Repository = "https://github.com/Strange-Metal/sunfield-sdk"
|
|
45
|
+
Documentation = "https://sunfield.dev/skill.md"
|
|
46
|
+
"Remote MCP Endpoint" = "https://sunfield.dev/mcp"
|
|
47
|
+
"Server Card" = "https://sunfield.dev/.well-known/mcp/server-card.json"
|
|
48
|
+
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
dev = [
|
|
51
|
+
"pytest>=8.3.0",
|
|
52
|
+
"pytest-asyncio>=0.24.0",
|
|
53
|
+
"ruff>=0.7.0",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[project.scripts]
|
|
57
|
+
sunfield-mcp = "sunfield_mcp.server:main"
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.wheel]
|
|
60
|
+
packages = ["sunfield_mcp"]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
addopts = "-v"
|
|
65
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
line-length = 120
|
|
69
|
+
target-version = "py311"
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = ["E4", "E7", "E9", "F", "I", "UP"]
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"""Official MCP server for Sunfield.
|
|
2
|
+
|
|
3
|
+
Exposes Sunfield's cloud 3D sandbox & Cycles render burst primitives as native MCP tools.
|
|
4
|
+
Notably, `sunfield_inspect` returns BOTH structured spatial telemetry JSON AND native
|
|
5
|
+
MCP `ImageContent` (base64 PNGs), letting multimodal agents directly see rendered views
|
|
6
|
+
and self-correct framing, collisions, and floating objects in a single tool call.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import base64
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import threading
|
|
15
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from mcp.types import ImageContent, TextContent
|
|
19
|
+
from sunfield import Sunfield
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
from mcp.server.mcpserver import MCPServer as _MCPServer
|
|
23
|
+
except ImportError:
|
|
24
|
+
from mcp.server.fastmcp import FastMCP as _MCPServer # type: ignore[assignment]
|
|
25
|
+
|
|
26
|
+
mcp = _MCPServer(
|
|
27
|
+
"sunfield",
|
|
28
|
+
instructions=(
|
|
29
|
+
"Sunfield provides stateful headless Blender 3D sandboxes with fast visual/spatial "
|
|
30
|
+
"inspection (`sunfield_inspect`) and elastic Cycles GPU burst (`sunfield_render`). "
|
|
31
|
+
"Workflow: create_session -> exec(bpy code) -> inspect(views + spatial telemetry) -> "
|
|
32
|
+
"iterate or fork() -> render(max_cost_usd) -> close_session."
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
_client_override: Sunfield | None = None
|
|
37
|
+
_client_lock = threading.Lock()
|
|
38
|
+
_cached_client: tuple[tuple[str, str], Sunfield] | None = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def set_client_override(client: Sunfield | None) -> None:
|
|
42
|
+
"""Inject a custom Sunfield client (used by integration tests)."""
|
|
43
|
+
global _client_override
|
|
44
|
+
_client_override = client
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _get_client() -> Sunfield:
|
|
48
|
+
global _cached_client
|
|
49
|
+
if _client_override is not None:
|
|
50
|
+
return _client_override
|
|
51
|
+
key = (os.environ["SUNFIELD_API_KEY"], os.environ.get("SUNFIELD_BASE_URL", "https://sunfield.dev"))
|
|
52
|
+
with _client_lock:
|
|
53
|
+
if _cached_client is not None and _cached_client[0] == key:
|
|
54
|
+
return _cached_client[1]
|
|
55
|
+
if _cached_client is not None:
|
|
56
|
+
_cached_client[1].close()
|
|
57
|
+
client = Sunfield(api_key=key[0], base_url=key[1])
|
|
58
|
+
_cached_client = (key, client)
|
|
59
|
+
return client
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@mcp.tool()
|
|
63
|
+
def sunfield_balance() -> str:
|
|
64
|
+
"""Return the current Sunfield account credit balance (USD) and recent ledger entries."""
|
|
65
|
+
bal = _get_client().balance()
|
|
66
|
+
return json.dumps(bal.model_dump(), indent=2)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@mcp.tool()
|
|
70
|
+
def sunfield_create_session(preset: str = "studio", pool: str = "interactive") -> str:
|
|
71
|
+
"""Create a warm, isolated headless Blender 3D sandbox session.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
preset: Initial scene preset ('studio', 'empty', or 'default').
|
|
75
|
+
pool: Worker pool ('interactive' or 'cycles').
|
|
76
|
+
"""
|
|
77
|
+
sess = _get_client().sessions.create(preset=preset, pool=pool)
|
|
78
|
+
return json.dumps(
|
|
79
|
+
{
|
|
80
|
+
"session_id": sess.session_id,
|
|
81
|
+
"worker_id": sess.worker_id,
|
|
82
|
+
"preset": sess.preset,
|
|
83
|
+
},
|
|
84
|
+
indent=2,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@mcp.tool()
|
|
89
|
+
def sunfield_list_sessions() -> str:
|
|
90
|
+
"""List active and recent Blender sandbox sessions for the current account."""
|
|
91
|
+
return json.dumps(_get_client().sessions.list(), indent=2)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@mcp.tool()
|
|
95
|
+
def sunfield_exec(session_id: str, code: str, timeout_s: float = 30.0) -> str:
|
|
96
|
+
"""Execute Python (`bpy`) code inside a live Blender session with crash auto-recovery.
|
|
97
|
+
|
|
98
|
+
Returns stdout, stderr, structured traceback on error, and `scene_diff`
|
|
99
|
+
(`added`, `removed`, `modified` object names).
|
|
100
|
+
"""
|
|
101
|
+
res = _get_client().sessions.get(session_id).exec(code, timeout_s=timeout_s)
|
|
102
|
+
return json.dumps(res.model_dump(), indent=2)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@mcp.tool()
|
|
106
|
+
def sunfield_inspect(
|
|
107
|
+
session_id: str,
|
|
108
|
+
views: list[str] | None = None,
|
|
109
|
+
passes: list[str] | None = None,
|
|
110
|
+
width: int = 512,
|
|
111
|
+
height: int = 512,
|
|
112
|
+
include_images: bool = True,
|
|
113
|
+
) -> list[TextContent | ImageContent]:
|
|
114
|
+
"""Render fast multi-view EEVEE previews + spatial telemetry (bounds, framing, collisions, floating objects).
|
|
115
|
+
|
|
116
|
+
Returns structured spatial JSON alongside native MCP ImageContent so multimodal models
|
|
117
|
+
can directly see rendered camera/top/front/iso_3q views.
|
|
118
|
+
"""
|
|
119
|
+
client = _get_client()
|
|
120
|
+
res = client.sessions.get(session_id).inspect(
|
|
121
|
+
views=views or ["camera", "iso_3q"],
|
|
122
|
+
passes=passes or ["rgb"],
|
|
123
|
+
resolution=(width, height),
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
summary: dict[str, Any] = {
|
|
127
|
+
"ok": res.ok,
|
|
128
|
+
"duration_ms": res.duration_ms,
|
|
129
|
+
"telemetry": res.telemetry,
|
|
130
|
+
"artifacts": [a.model_dump() for a in res.artifacts],
|
|
131
|
+
"error": res.error,
|
|
132
|
+
}
|
|
133
|
+
blocks: list[TextContent | ImageContent] = [
|
|
134
|
+
TextContent(type="text", text=json.dumps(summary, indent=2))
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
if include_images and res.ok and res.artifacts:
|
|
138
|
+
if len(res.artifacts) == 1:
|
|
139
|
+
raws = [client.download_artifact(res.artifacts[0].artifact_id)]
|
|
140
|
+
else:
|
|
141
|
+
with ThreadPoolExecutor(max_workers=min(8, len(res.artifacts))) as pool:
|
|
142
|
+
raws = list(pool.map(lambda a: client.download_artifact(a.artifact_id), res.artifacts))
|
|
143
|
+
for png_bytes in raws:
|
|
144
|
+
blocks.append(
|
|
145
|
+
ImageContent(
|
|
146
|
+
type="image",
|
|
147
|
+
data=base64.b64encode(png_bytes).decode("ascii"),
|
|
148
|
+
mimeType="image/png",
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
return blocks
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@mcp.tool()
|
|
155
|
+
def sunfield_fork(session_id: str, count: int = 2) -> str:
|
|
156
|
+
"""Branch a live scene into `count` independent child sessions for parallel exploration."""
|
|
157
|
+
children = _get_client().sessions.get(session_id).fork(count=count)
|
|
158
|
+
return json.dumps(
|
|
159
|
+
{
|
|
160
|
+
"source_session_id": session_id,
|
|
161
|
+
"session_ids": [c.session_id for c in children],
|
|
162
|
+
},
|
|
163
|
+
indent=2,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@mcp.tool()
|
|
168
|
+
def sunfield_render(
|
|
169
|
+
session_id: str,
|
|
170
|
+
engine: str = "cycles",
|
|
171
|
+
samples: int = 64,
|
|
172
|
+
width: int = 1024,
|
|
173
|
+
height: int = 1024,
|
|
174
|
+
frames: list[int] | None = None,
|
|
175
|
+
aov_passes: list[str] | None = None,
|
|
176
|
+
max_cost_usd: float = 1.0,
|
|
177
|
+
) -> str:
|
|
178
|
+
"""Burst-render final photorealistic or ground-truth AOV frames on OptiX GPUs.
|
|
179
|
+
|
|
180
|
+
Runs an automatic pre-flight sample probe and aborts if projected cost > `max_cost_usd`.
|
|
181
|
+
"""
|
|
182
|
+
res = _get_client().sessions.get(session_id).render(
|
|
183
|
+
engine=engine,
|
|
184
|
+
samples=samples,
|
|
185
|
+
resolution=(width, height),
|
|
186
|
+
frames=frames or [1],
|
|
187
|
+
aov_passes=aov_passes or ["rgb"],
|
|
188
|
+
max_cost_usd=max_cost_usd,
|
|
189
|
+
)
|
|
190
|
+
return json.dumps(res.model_dump(), indent=2)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@mcp.tool()
|
|
194
|
+
def sunfield_close_session(session_id: str) -> str:
|
|
195
|
+
"""Terminate a Blender sandbox session and settle its final compute charge."""
|
|
196
|
+
res = _get_client().sessions.get(session_id).close()
|
|
197
|
+
return json.dumps(res, indent=2)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def main() -> None:
|
|
201
|
+
mcp.run(transport=os.environ.get("SUNFIELD_MCP_TRANSPORT", "stdio"))
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
if __name__ == "__main__":
|
|
205
|
+
main()
|