Program the Nexus agent in your installed Cosmon app — drive SolidWorks, Abaqus, COMSOL, Fluent and more.
Project description
Cosmon Agent SDK (Python)
⚠️ Alpha. This SDK is an early release: the API surface is still moving and breaking changes will ship in minor versions while we're on
0.x. Pin an exact version (cosmon-agent-sdk==0.1.1) in anything you don't want to fix on upgrade day, and read the CHANGELOG before bumping.
Program the Nexus agent in your installed, signed-in Cosmon app — drive SolidWorks, Abaqus, COMSOL, Fluent, Ansys Mechanical and more from your own Python. Your code brings the caller; the installed app brings the capability (your login, your credits, the CAD software on your machine). Your code never holds a key.
Under the hood the SDK is a small MCP client:
it discovers the running app, connects to the local MCP server it exposes, and
drives the agent through one run tool.
Install
pip install cosmon-agent-sdk
Then: open Cosmon, sign in, and turn on Settings → Developer access.
Check it's working:
cosmon doctor
Quickstart
client.run() returns a Run; get the agent's final answer with .text():
from cosmon_agent_sdk import Client
with Client() as client:
answer = client.run("What's the max von Mises in bracket.sldprt?", agent="solidworks").text()
print(answer)
Or iterate the run to stream it — it yields typed ToolCall / TextChunk
events (.text() and iterating are the two ways to consume a run; pick one):
import sys
from cosmon_agent_sdk import Client, TextChunk, ToolCall
with Client() as client:
for event in client.run("Run a static study on bracket.sldprt", agent="solidworks"):
if isinstance(event, TextChunk):
print(event.text, end="", flush=True) # answer, token by token
elif isinstance(event, ToolCall) and not event.finished:
print(f"[{event.summary}]", file=sys.stderr) # tool steps
Attended vs unattended
Interactivity is set when you build the client, by whether you supply handlers:
- Unattended (default) — no handlers. The agent is never offered
ask_user(it proceeds on its own) and confirmations are auto-resolved (approve safe, decline dangerous)..text()just runs to completion. This is the headless path; put any decisions the agent might otherwise ask about in the prompt. - Interactive — supply
on_questionand/oron_confirm. The app forwards the agent'sask_user/confirm_actionto your handlers (over MCP elicitation) while.text()runs to completion. There's no event loop to drive — your handlers are called as needed, so.text()never stalls waiting for an answer.
from cosmon_agent_sdk import Client, Question, Confirmation
def answer(question: Question) -> str:
return question.options[0] if question.options else "10mm seed size"
def approve(confirmation: Confirmation) -> bool:
return True # your policy here
with Client(on_question=answer, on_confirm=approve) as client:
print(client.run("Mesh the model and submit the job", agent="abaqus").text())
Long runs
The agent can work for many minutes (mesh, solve, post-process). The client sets
a generous default timeout (10 minutes) and you can raise it:
with Client(timeout=1800) as client: # 30 minutes
client.run("Run a mesh-convergence study on bracket.sldprt", agent="solidworks").text()
Async
AsyncClient is the async twin (for pipelines, FastAPI, etc.) — same surface,
awaited:
import asyncio
from cosmon_agent_sdk import AsyncClient
async def main() -> None:
async with AsyncClient() as client:
print(await client.run("what can you do?", agent="nexus").text())
asyncio.run(main())
Client/AsyncClient and Run/AsyncRun are the sync/async pairs.
Command line
cosmon doctor # check the connection, step by step
cosmon run "mesh and solve" --agent abaqus # stream the work (steps to stderr)
cosmon run "what can you do?" --agent nexus -q # -q: print just the final answer
The CLI is headless (it can't answer ask_user); --auto-approve additionally
approves confirmation requests, including dangerous ones.
Notes
- Discovery: the app writes a
mcp-gateway.jsondescriptor while Developer access is on; the SDK reads it automatically. Override with theCOSMON_SDK_DESCRIPTORenvironment variable. - Errors: connecting / starting a run can raise
CosmonConnectionError,CosmonAuthError,CosmonTimeoutError,CosmonProtocolError; a run that fails while running raisesCosmonRunErrorfrom.text(). - Docs: https://docs.cosmon.com/
Project details
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 cosmon_agent_sdk-0.1.3.tar.gz.
File metadata
- Download URL: cosmon_agent_sdk-0.1.3.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d33d1ea8a9458b2df561a53844c25f952d68eaad68c10a4b0227a473ac33acda
|
|
| MD5 |
b593f7fd532509ae106c1adebb7493d6
|
|
| BLAKE2b-256 |
9c164b58d2f7f837314aa5cab8131e8510b46f9621ccb1ee11ada895c4b1175a
|
Provenance
The following attestation bundles were made for cosmon_agent_sdk-0.1.3.tar.gz:
Publisher:
cosmon-agent-sdk-publish.yml on Cosmon-Inc/cosmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cosmon_agent_sdk-0.1.3.tar.gz -
Subject digest:
d33d1ea8a9458b2df561a53844c25f952d68eaad68c10a4b0227a473ac33acda - Sigstore transparency entry: 2128223438
- Sigstore integration time:
-
Permalink:
Cosmon-Inc/cosmon@e34b1fa9dd3e33aee0153919ab0840d78b970d40 -
Branch / Tag:
refs/tags/cosmon-agent-sdk-v0.1.3 - Owner: https://github.com/Cosmon-Inc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cosmon-agent-sdk-publish.yml@e34b1fa9dd3e33aee0153919ab0840d78b970d40 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cosmon_agent_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: cosmon_agent_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b987f5abea072f02bf1096fd8f5de3f2bc6e62ebb8d7c52f4ac23ce585a952f
|
|
| MD5 |
68b29d3bcf7bba177dcffdc64d9b1ab0
|
|
| BLAKE2b-256 |
6db1aec2c4252cc81787d9173212c72c07e90d3c3ec9845d8cb4211b60763e36
|
Provenance
The following attestation bundles were made for cosmon_agent_sdk-0.1.3-py3-none-any.whl:
Publisher:
cosmon-agent-sdk-publish.yml on Cosmon-Inc/cosmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cosmon_agent_sdk-0.1.3-py3-none-any.whl -
Subject digest:
8b987f5abea072f02bf1096fd8f5de3f2bc6e62ebb8d7c52f4ac23ce585a952f - Sigstore transparency entry: 2128223679
- Sigstore integration time:
-
Permalink:
Cosmon-Inc/cosmon@e34b1fa9dd3e33aee0153919ab0840d78b970d40 -
Branch / Tag:
refs/tags/cosmon-agent-sdk-v0.1.3 - Owner: https://github.com/Cosmon-Inc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cosmon-agent-sdk-publish.yml@e34b1fa9dd3e33aee0153919ab0840d78b970d40 -
Trigger Event:
push
-
Statement type: