Installation
Install the Heimdall JavaScript SDK from npm:Basic Usage
Initialize the Client
Trace MCP Tools
UsetraceMCPTool to wrap your MCP tool functions:
Flush Traces
Always flush traces before your application exits:Configuration Options
ThetraceMCPTool function accepts the following options:
General Tracing with observe
For non-MCP functions or when you need more control:
Error Handling
Errors are automatically captured and the span is marked as failed:Complete Example
Here’s a complete example of an MCP server instrumented with Heimdall:TypeScript Support
The SDK is written in TypeScript and provides full type definitions. Your traced functions maintain their original type signatures:Next Steps
Environment Variables
Configure Heimdall using environment variables.
SDK Options
Explore all available configuration options.