Metadata-Version: 2.4
Name: npc-protocol
Version: 0.2.0
Summary: Python SDK for building NPC Protocol servers
Project-URL: Homepage, https://github.com/macropulse/npc-protocol
Project-URL: Documentation, https://github.com/macropulse/npc-protocol/tree/main/spec
Project-URL: Repository, https://github.com/macropulse/npc-protocol
Project-URL: Issues, https://github.com/macropulse/npc-protocol/issues
License: Apache-2.0
Keywords: agent,ai,mcp,npc,protocol
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: mcp>=1.0.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: redis
Requires-Dist: redis>=5.0.0; extra == 'redis'
Description-Content-Type: text/markdown

# npc-protocol

Python SDK for building [NPC Protocol](https://github.com/macropulse/npc-protocol) servers.

**Stop selling APIs. Wrap yourself into an NPC and let it earn for you while you sleep.**

---

## What is NPC Protocol?

NPC Protocol is an open standard for packaging domain knowledge as a "black box" agent service that AI agents can delegate to — in natural language, with persistent memory and explicit safety contracts. Built on top of MCP.

> *Your coworker became a skill. Your ex became a skill. Now it's your turn.*

## Install

```bash
pip install npc-protocol
```

## Quick Start

```python
from npc import NPCServer, NPCCard, NPCContext
from npc.response import GateLevel

card = NPCCard(
    name="DNS Manager",
    domain="DNS record management",
    confirmation_gates=[
        {"id": "delete_zone", "level": "destructive", "description": "Deleting a DNS zone"}
    ],
)

npc = NPCServer(card=card)

@npc.instruction_handler
async def handle(instruction: str, session_id: str, ctx: NPCContext):
    if "delete" in instruction.lower():
        return ctx.require_confirmation(
            gate_id="delete_zone",
            gate_level=GateLevel.DESTRUCTIVE,
            prompt="This will permanently delete the zone and all its records.",
            protected_resources=[
                {"type": "dns_zone", "name": "example.com", "risk": "All DNS records deleted"}
            ],
        )
    return ctx.complete(result="DNS record updated")

npc.run()
```

## Links

- [Full spec and docs](https://github.com/macropulse/npc-protocol)
- [NPC Card spec](https://github.com/macropulse/npc-protocol/blob/main/spec/npc-card.md)
- [Confirmation Gates spec](https://github.com/macropulse/npc-protocol/blob/main/spec/confirmation-gate.md)

## License

Apache 2.0
