Skip to content

Models

ToolResult

Standardized result for all action executions. Backed by a Rust struct via PyO3.

Fields

FieldTypeDefaultDescription
successboolTrueWhether the execution was successful
messagestr""Human-readable result description
promptOptional[str]NoneSuggestion for AI about next steps
errorOptional[str]NoneError message when success is False
contextDict[str, Any]{}Additional context data

Methods

MethodReturnsDescription
with_error(error)ToolResultCreate copy with error info (sets success=False)
with_context(**kwargs)ToolResultCreate copy with updated context
to_dict()Dict[str, Any]Convert to dictionary
to_json()strSerialize to a JSON string
__eq__(other)boolEquality comparison
__str__()strHuman-readable string
__repr__()strUnambiguous representation

json.dumps() is not supported directly

ToolResult is a Rust-backed object and cannot be passed to json.dumps() directly. Use to_json() or convert to a dict first:

python
import json
result = success_result("done")

# Option 1 — built-in JSON serializer (recommended, uses Rust serde)
json_str = result.to_json()

# Option 2 — via dict
json_str = json.dumps(result.to_dict())

# Option 3 — serialize_result (supports JSON and MsgPack)
from dcc_mcp_core import serialize_result
json_str = serialize_result(result)

Factory Functions

python
from dcc_mcp_core import success_result, error_result, from_exception, validate_action_result, ToolResult

# Success result with context
result = success_result("Created 5 spheres", prompt="Use modify_spheres next", count=5)

# Error result with possible solutions
error = error_result(
    "Failed", "File not found",
    prompt="Check path",
    possible_solutions=["Verify file exists", "Check permissions"],
    path="/bad/path",
)

# From exception string
exc_result = from_exception(
    "ValueError: bad input",
    message="Import failed",
    include_traceback=True,
)

# Validate/normalize any value to ToolResult
validate_action_result(result)                          # pass-through
validate_action_result({"success": True, "message": "OK"})  # dict → ARM
validate_action_result("hello")                         # wrap as success

Factory Function Signatures

FunctionSignatureDescription
success_result(message, prompt=None, **context) -> ToolResultCreate a successful result
error_result(message, error, prompt=None, possible_solutions=None, **context) -> ToolResultCreate a failed result
from_exception(error_message, message=None, prompt=None, include_traceback=True, possible_solutions=None, **context) -> ToolResultWrap an exception as a result
validate_action_result(result: Any) -> ToolResultNormalize dict/str/None/ToolResult → ToolResult

SkillMetadata

Metadata parsed from SKILL.md frontmatter. All fields are readable and writable.

Fields

FieldTypeDefaultDescription
namestrUnique identifier
descriptionstr""Human-readable description
toolslist[ToolDeclaration][]Declared tools parsed from SKILL.md
dccstr"python"Target DCC application
tagslist[str][]Classification tags
scriptslist[str][]Discovered script file paths
skill_pathstr""Absolute path to skill directory
versionstr"1.0.0"Skill version
dependslist[str][]Names of required skills
metadata_fileslist[str][]Files in metadata/ directory
licensestr""License identifier
compatibilitystr""Compatibility string
allowed_toolslist[str][]Allowed tool names (restricts which tools can be registered)
groupslist[SkillGroup][]Tool groups for progressive exposure

Released under the MIT License.