TypeScript SDK
The synapse-layer package on npm provides TypeScript type definitions for Synapse Layer. For full client functionality, use the REST API or MCP integration.
Installation
npm install synapse-layer
# or
yarn add synapse-layerRequires Node.js 18+. The package provides TypeScript type definitions for Synapse Layer data structures and API responses.
Note
fetch or any HTTP library, or connect via MCP for tool-based interaction.Quick Start
Use the REST API from TypeScript with full type safety:
const FORGE_URL = "https://forge.synapselayer.org"
const TOKEN = "sk_connect_your_token"
// Store a memory
const storeRes = await fetch(`${FORGE_URL}/api/v1/memory/commit`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-connect-token": TOKEN,
},
body: JSON.stringify({
agent: "my-agent",
content: "User prefers TypeScript and dark mode",
memoryType: "long_term",
}),
})
const stored = await storeRes.json()
console.log("Memory ID:", stored.memoryId)
// Recall memories
const recallRes = await fetch(`${FORGE_URL}/api/v1/sdk/recall`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-connect-token": TOKEN,
},
body: JSON.stringify({
query: "user preferences",
limit: 5,
}),
})
const { memories } = await recallRes.json()
memories.forEach((m: any) => console.log(m.content, m.trust_quotient))REST API Alternative
For production TypeScript/Node.js applications, the REST API provides the most complete interface. All endpoints accept JSON payloads and return structured responses.
See the REST API Reference for complete endpoint documentation.
MCP Integration
For MCP-compatible clients (Claude Desktop, Cursor, etc.), Synapse Layer exposes 13 tools via the MCP protocol. Connect using Streamable HTTP:
{
"mcpServers": {
"synapse-layer": {
"url": "https://forge.synapselayer.org/api/mcp",
"transport": "streamable-http",
"headers": {
"x-connect-token": "sk_connect_your_token"
}
}
}
}See the MCP Overview for detailed setup instructions.