Skip to main content

SDK for the Mark AI Agent Workflow Marketplace — search, buy, and rate pre-solved reasoning workflows for your AI agents.

Project description

marktools

The SDK that lets AI agents buy pre-solved reasoning workflows.

PyPI Python License

marktools gives your AI agents access to a marketplace of expert-crafted, pre-solved reasoning workflows. Instead of spending thousands of tokens figuring out how to file Ohio taxes or plan a multi-city trip from scratch, your agent calls mark.estimate(), gets a price quote, and buys a battle-tested solution — complete with step-by-step instructions, edge cases, and domain knowledge.

Quick Start

pip install marktools

3 Lines to Supercharge Any Agent

from marktools import MarkClient

mark = MarkClient(api_key="mk_...")  # or set MARK_API_KEY env var

# 1. Estimate — is the marketplace worth it? (free, no credits)
estimate = mark.estimate("File Ohio 2024 taxes with W2 and itemized deductions")

# 2. Buy — purchase the best solution
receipt = mark.buy(estimate.session_id, estimate.best_solution.solution_id)

# 3. Use — step-by-step instructions, edge cases, domain knowledge
for wf in receipt.execution_plan.workflows:
    print(f"📋 {wf.workflow_title}")
    for step in wf.workflow.steps:
        print(f"  Step {step['step']}: {step['thought']}")

One-shot: solve()

# Auto-estimate + auto-buy the best solution in one call
receipt = mark.solve("File Ohio 2024 taxes with W2 and itemized deductions")
print(f"Tokens charged: {receipt.tokens_charged}")

Use with Claude (Anthropic)

from marktools import MarkTools
from anthropic import Anthropic

mark = MarkTools(api_key="mk_...")
client = Anthropic()

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=4096,
    tools=mark.to_anthropic(),   # ← plug in the tools
    messages=[{"role": "user", "content": "Help me file my Ohio taxes for 2024"}],
)

# Execute tool calls
for block in response.content:
    if block.type == "tool_use":
        result = mark.execute(block.name, block.input)
        print(f"Tool: {block.name}{result[:200]}")

Use with OpenAI

from marktools import MarkTools
from openai import OpenAI

mark = MarkTools(api_key="mk_...")
client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4o",
    tools=mark.to_openai(),      # ← plug in the tools
    messages=[{"role": "user", "content": "Help me file my Ohio taxes for 2024"}],
)

# Execute tool calls
for call in response.choices[0].message.tool_calls or []:
    import json
    result = mark.execute(call.function.name, json.loads(call.function.arguments))

Use with LangChain

from marktools import MarkTools

mark = MarkTools(api_key="mk_...")
tool_definitions = mark.to_langchain()

Tools Reference

marktools exposes 3 core tools + 1 optional:

Tool Cost Description
mark_estimate Free Search marketplace, get pricing & ranked solutions
mark_buy Credits Purchase solution, get full execution plan
mark_rate Free Rate a workflow after use (improves marketplace)
mark_search Free Browse/filter marketplace workflows

mark_estimate — Search & Price

estimate = mark.client.estimate(
    query="File Ohio 2024 taxes with W2 and itemized deductions",
    context={"state": "ohio", "year": 2024, "income": 87000}
)

# Returns ranked solutions:
for sol in estimate.solutions:
    print(f"  {sol.solution_id}: {sol.pricing.total_cost_tokens} tokens "
          f"({sol.pricing.savings_percentage}% savings)")

mark_buy — Purchase Solution

receipt = mark.client.buy(
    session_id=estimate.session_id,
    solution_id="sol_1"
)

# Full execution plan with steps, edge cases, domain knowledge:
for wf in receipt.execution_plan.workflows:
    for step in wf.workflow.steps:
        print(f"  {step['step']}. {step['action']}: {step['thought']}")

mark_rate — Post-Use Feedback

mark.client.rate("ohio_w2_itemized_2024", rating=5)
# or
mark.client.rate("ohio_w2_itemized_2024", vote="up")

Privacy-First Architecture

All data is sanitized before hitting the marketplace:

result = mark.client.sanitize({
    "name": "John Smith",           # ← removed
    "ssn": "123-45-6789",           # ← removed
    "exact_income": 87432.18,       # ← bucketed to "80k-100k"
    "state": "ohio",                # ← kept
    "year": 2024,                   # ← kept
})
# public_query: {"state": "ohio", "year": 2024, "exact_income": "80k-100k"}
# private_data: {"name": "John Smith", "ssn": "123-45-6789"}

Names, SSNs, emails, and exact incomes never leave the agent's local environment.


Models

All responses are typed Pydantic models:

from marktools import (
    Workflow,           # Marketplace workflow template
    Solution,           # Ranked solution candidate
    EstimateResult,     # Response from estimate()
    PurchaseReceipt,    # Response from buy()
    RateResult,         # Response from rate()
)

Configuration

from marktools import MarkClient

# Option 1: Pass API key directly
mark = MarkClient(api_key="mk_...")

# Option 2: Environment variable
# export MARK_API_KEY=mk_...
mark = MarkClient()

# Option 3: Custom API URL (self-hosted)
# export MARK_API_URL=http://localhost:5001
mark = MarkClient(base_url="http://localhost:5001")
Env Variable Description Default
MARK_API_KEY Your API key
MARK_API_URL API base URL https://api.mark.ai

Development

# Clone the repo
git clone https://github.com/akhaire21/treehacks-2026
cd treehacks-2026/marktools

# Install in dev mode
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy src/marktools

# Lint
ruff check src/

License

MIT

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

marktools-0.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marktools-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file marktools-0.1.0.tar.gz.

File metadata

  • Download URL: marktools-0.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for marktools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a733c8698d9d05934968bee7155d786ef4c9665927158aed5e38cd3f7d55d3b
MD5 96d0cfe4c0b6c798a5b655b1f071595a
BLAKE2b-256 2b8e4d1b737080132f4892c3d73daf18525a15b1533fa3b71b638744237076b9

See more details on using hashes here.

File details

Details for the file marktools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: marktools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for marktools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b65006196c0b5cb074985385e674e2a55434525b07936c25b54fa6c4faf96814
MD5 533dd27a15332a65d52b084c261393fa
BLAKE2b-256 6b89f06cba6da982a618eb3ca6f0dd24f2666c76e0a873f3a6b1df828f1f8bd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page