Skip to main content

Python framework to build streaming APIs and MCP tools from skill folders

Project description

harnessapi

Python Skill Framework for MCP Tools and Streaming APIs

Write a skill. Get an API. Get an MCP tool. Ship.

PyPI version Python 3.11+ License: MIT

Built on FastAPI Powered by FastMCP agentskills.io compatible


harnessapi is a Python framework that turns a skill folder into a streaming HTTP API and a Model Context Protocol (MCP) tool simultaneously — no routes, no decorators, no separate MCP server to maintain.

skills/summarize/
├── models.py    ← define input & output
├── handler.py   ← write your logic
└── skill.toml   ← name, description, tags, timeout

Drop the folder. Run the server. Your skill is live as an HTTP endpoint, an MCP tool, and in Swagger docs.


Contents


Why harnessapi

Use harnessapi when you are:

  • Building tools for Claude Desktop, Cursor, Copilot, or any MCP client
  • Exposing Python functions as streaming API endpoints (Server-Sent Events)
  • Converting an agentskills.io skill folder into a production API
  • Shipping an LLM-powered microservice without FastAPI boilerplate
  • Wrapping any Python function as an MCP tool in under a minute

Quick start

uv add harnessapi

skills/summarize/models.py

from harnessapi import SkillInput, SkillOutput

class Input(SkillInput):
    text: str
    max_length: int = 200

class Output(SkillOutput):
    summary: str

skills/summarize/handler.py

from .models import Input, Output

async def handle(input: Input) -> Output:
    return Output(summary=input.text[:input.max_length])

skills/summarize/skill.toml

[skill]
description  = "Summarize text to a target length"
is_mcp       = true
tags         = ["text"]
timeout_secs = 30

main.py

from pathlib import Path
from harnessapi import HarnessAPI

app = HarnessAPI(skills_dir=Path(__file__).parent / "skills")
harnessapi run

Your skill is live at three places simultaneously:

Endpoint Details
POST /skills/summarize HTTP endpoint — SSE streaming by default
GET /docs Interactive OpenAPI / Swagger UI
http://localhost:8000/mcp MCP server — ready for Claude, Cursor, Copilot

Try it instantly with uvx

No install needed. uvx runs harnessapi in an isolated environment:

# Scaffold a new project
uvx harnessapi init my-project

# Enter and run it
cd my-project
uvx harnessapi run

Then call your skill:

# Streaming (SSE — default)
curl -X POST http://localhost:8000/skills/greet \
  -H "Content-Type: application/json" \
  -d '{"name": "world"}'

# Plain JSON
curl -X POST http://localhost:8000/skills/greet \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"name": "world"}'
{"message": "Hello, world! Welcome to harnessapi.", "length": 36}

Streaming — just use yield

Return a value for a single response. Use yield to stream chunks as they're produced. Same endpoint, same URL, no extra config.

# Non-streaming — return a value
async def handle(input: Input) -> Output:
    return Output(result=compute(input))

# Streaming — yield chunks
async def handle(input: Input):
    async for token in llm.stream(input.prompt):
        yield token

Clients receive standard Server-Sent Events (SSE):

event: chunk
data: The answer is

event: chunk
data: 42.

event: done
data:

Need plain JSON? Add Accept: application/json — harnessapi collects all chunks and returns them together. Same handler, zero changes.


Every skill is an MCP tool

Every skill folder is automatically registered as a Model Context Protocol (MCP) tool. No extra code required.

{
  "mcpServers": {
    "my-skills": {
      "url": "http://localhost:8000/mcp"
    }
  }
}

Add a skill folder → restart the server → it appears as an MCP tool. No registration. No schema maintenance.


Works with

Client How to connect
Claude Desktop Add http://localhost:8000/mcp as an MCP server in settings
Cursor Add under MCP Servers in Cursor settings
Copilot / VS Code Any MCP-compatible client works
agentskills.io Drop-in compatible — existing skill folders work as-is
Any HTTP client POST /skills/{name} — curl, httpx, fetch

Scaffold in one command

# New project with a sample greet skill
harnessapi init my-project

# Add API + MCP layer to an existing agentskills.io skill folder
harnessapi init --skill .agents/skills/summarize

# Convert an entire skills directory at once
harnessapi init --skills-dir .agents/skills

# Wrap a plain Python function as a skill
harnessapi init --function utils/compute.py --output skills

harnessapi is a compatible superset of the agentskills.io standard — existing skill folders with a SKILL.md are detected automatically.


Example: streaming factorial (SSE + MCP)

git clone https://github.com/edwinjosechittilappilly/harnessapi
cd harnessapi
uv sync
uv run uvicorn examples.factorial_app.main:app --reload
curl -X POST http://localhost:8000/skills/factorial \
  -H "Content-Type: application/json" \
  -d '{"n": 5}'
event: chunk
data: start: 1

event: chunk
data: 2: 2

event: chunk
data: 3: 6

event: chunk
data: 4: 24

event: chunk
data: 5: 120

event: done
data:

Or collect everything as JSON:

curl -X POST http://localhost:8000/skills/factorial \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"n": 5}'
{"chunks": ["start: 1", "2: 2", "3: 6", "4: 24", "5: 120"]}

Skill folder reference

skills/
└── my_skill/
    ├── handler.py        ← required: your logic
    ├── models.py         ← required: Pydantic Input + Output
    ├── SKILL.md          ← optional: agentskills.io compatible metadata
    ├── skill.toml        ← optional: name, description, tags, timeout
    ├── defaults/
    │   └── input.json    ← optional: default values shown in /docs
    └── examples/
        └── 01.json       ← optional: {input, output} pairs for docs

skill.toml

[skill]
description  = "What this skill does"
is_mcp       = true      # set false to hide from MCP
tags         = ["nlp"]
timeout_secs = 30

Hot-swap handlers at runtime

Patch a running skill handler without restarting the server:

app = HarnessAPI(skills_dir="./skills", enable_edit_endpoints=True)
curl -X POST http://localhost:8000/skills/summarize/edit \
  -H "Content-Type: application/json" \
  -d '{"source_code": "async def handle(input):
    return Output(summary=input.text.upper())", "persist": true}'

Disabled by default. Add auth middleware before enabling in production.


Features

Feature Details
HTTP endpoint POST /skills/{name} for every skill, automatically
Streaming SSE by default · JSON via Accept: application/json
MCP server /mcp · all skills auto-registered as MCP tools
OpenAPI docs /docs · full Swagger UI, zero config
Pydantic validation Invalid input rejected before your handler runs
Timeouts Per-skill timeout_secs in skill.toml
Hot-swap Runtime handler replacement via opt-in edit endpoint
agentskills.io Drop-in compatible — existing skill folders just work
CLI scaffold uvx harnessapi init · --skill · --skills-dir · --function

Philosophy

Most frameworks start with routes. Most agent frameworks start with tools. harnessapi starts with skills — the capability itself. The HTTP API and the MCP tool are consequences, not configuration.

Write the thing. Everything else follows.


See also


Built on FastAPI · FastMCP · Pydantic · uv

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

harnessapi-0.1.5.tar.gz (639.6 kB view details)

Uploaded Source

Built Distribution

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

harnessapi-0.1.5-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file harnessapi-0.1.5.tar.gz.

File metadata

  • Download URL: harnessapi-0.1.5.tar.gz
  • Upload date:
  • Size: 639.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for harnessapi-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bf0c4612b737d8abc8351533236b454a445a8b3ea430ddf9356e6ee0c3ebf569
MD5 0871ceada1efc41b8d16392273d1c27c
BLAKE2b-256 6b68f10853624704993b9e2531f16262cee33352e563abb34f6c0bd6935d4ca7

See more details on using hashes here.

File details

Details for the file harnessapi-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: harnessapi-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for harnessapi-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2ae0f864117fdfb61675e36b1995a164cca223fbd4c9d75a8a09beaec1d19f58
MD5 743cb8ce638adecd23e23e21fb34a385
BLAKE2b-256 8ae34d2083d4903c83a6fca81cb86389b8202978a0f36bb8ec0361f2b10b0083

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