intentkit-rest
v1.2.0
Published
REST API bridge for exposing IntentKit functions as HTTP endpoints
Maintainers
Readme
intentkit-rest
REST API bridge for exposing IntentKit functions as HTTP endpoints. Allows non-MCP consumers (web frontends, mobile apps, other services) to call IntentKit functions via standard HTTP.
Install
npm install intentkit-rest intentkitUsage
import { IntentRegistry, createContext } from 'intentkit';
import { startRestBridge } from 'intentkit-rest';
const registry = new IntentRegistry().register(/* your functions */);
const context = await createContext({ dbPath: './data.db' });
const handle = await startRestBridge({
registry,
context,
roles: {
admin: ['*'],
viewer: ['task:read'],
},
defaultRole: 'viewer',
port: 3200,
});
console.log(`REST bridge at ${handle.url}`);Routes
| Method | Path | Description |
|--------|------|-------------|
| GET | /api/health | Health check |
| GET | /api/catalog | List visible functions (filtered by role) |
| POST | /api/functions/:name | Execute a function |
Role Resolution
By default, the role is read from the X-IntentKit-Role header. Provide a custom roleResolver for other auth patterns:
startRestBridge({
roleResolver: (req) => {
const token = req.headers.authorization?.replace('Bearer ', '');
return decodeRole(token); // your logic
},
});License
MIT
