Skip to main content

Overview

Custom adapters allow you to integrate any agent runtime with Paperclip. Whether you’re building a proprietary AI system, integrating with third-party platforms, or experimenting with novel execution models, the adapter interface provides full flexibility.
This guide covers building server-side adapters. For UI and CLI integration, see the full adapter development documentation.

Adapter Interface

Every adapter implements the ServerAdapterModule interface:

Required Fields

Optional Fields

The execute Function

execute is the core of your adapter. It receives context and returns results:

Execution Context

Agent Metadata

Runtime State

Execution Result

Example: Simple HTTP Agent

Here’s a complete example of a custom HTTP-based adapter:

Session Management

If your adapter supports stateful sessions, implement a sessionCodec:

Using Sessions in execute

Environment Testing

testEnvironment validates adapter configuration before execution:

Registering Your Adapter

Add your adapter to the server’s adapter registry:

Utility Functions

Use helper functions from @paperclipai/adapter-utils/server-utils:

Best Practices

Check required fields and return clear errors:
Return machine-readable error codes for common failures:
Stream logs via onLog for real-time visibility:
Always return usage data for cost tracking:
Use abort controllers and return timeout status:

Testing Your Adapter

Unit Tests

Integration Tests

Test against a real endpoint:

Next Steps

Process Adapters

Learn from the built-in process adapter implementations

HTTP Adapters

Understand HTTP-based adapter patterns

Adapter Utils Reference

Full API reference for adapter utilities

Contributing

Contribute your adapter back to Paperclip