msgpackr pack and unpack structured values: working versions (tested 2026-10-15)
Encode and decode nested objects and binary buffers with msgpackr pack/unpack offline.
passed2 passed · 0 failed2026-10-15 20:57 UTC- Status
- passed
- Last passed
- 2026-10-15 20:57 UTC
- Tests
- 2 / 2
- Language
- TypeScript
- Runtime
- node v22.23.3
pinned versions3
msgpackr@2.1.0@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false npm test
test environment
node v22.23.3 linux 6.17.0-1022-azure x64 runner: github-actions 38805962781
The code
Exactly the files that passed. Your agent can pull them with get_recipe("msgpackr-encode-decode") (install), or see them on GitHub.
package.json
{
"name": "msgpackr-encode-decode",
"private": true,
"type": "module",
"scripts": {
"test": "node --import tsx --test test/*.test.ts"
},
"dependencies": {
"msgpackr": "2.1.0"
},
"devDependencies": {
"@types/node": "26.6.5",
"tsx": "4.23.15"
}
}
src/codec.ts
import { pack, unpack } from "msgpackr";
export type Payload = {
id: number;
name: string;
tags: string[];
meta: { ok: boolean; score: number };
};
export function encode(value: Payload): Buffer {
return pack(value) as Buffer;
}
export function decode(buf: Buffer): Payload {
return unpack(buf) as Payload;
}
test/codec.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { decode, encode } from "../src/codec.ts";
test("roundtrips nested payload", () => {
const value = {
id: 42,
name: "widget",
tags: ["a", "b"],
meta: { ok: true, score: 9.5 },
};
const buf = encode(value);
assert.ok(Buffer.isBuffer(buf));
assert.deepEqual(decode(buf), value);
});
test("produces compact binary", () => {
const buf = encode({ id: 1, name: "x", tags: [], meta: { ok: false, score: 0 } });
assert.ok(buf.length < 64);
});
Connect to ProvenPin
Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.
terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp
~/.cursor/mcp.json
{ "mcpServers": { "provenpin": { "url": "https://mcp.provenpin.com/mcp" } } }.vscode/mcp.json
{ "servers": { "provenpin": { "type": "http", "url": "https://mcp.provenpin.com/mcp" } } }~/.codeium/windsurf/mcp_config.json
{ "mcpServers": { "provenpin": { "serverUrl": "https://mcp.provenpin.com/mcp" } } }MCP settings
{ "mcpServers": { "provenpin": { "type": "streamableHttp", "url": "https://mcp.provenpin.com/mcp" } } }Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.