npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-samply

v0.1.0

Published

MCP server for recording and analyzing samply profiles

Downloads

24

Readme

mcp-samply

mcp-samply is a MCP server for samply.

It is designed for AI agents that need to:

  • record CPU profiles with samply
  • load existing profile.json / profile.json.gz files
  • turn Firefox Profiler data into compact, agent-friendly hotspot summaries
  • drill down into specific threads and functions

The intended runtime is:

npx mcp-samply

Why this exists

samply is excellent at recording profiles and opening them in Firefox Profiler, but AI agents need a second layer:

  • a stable MCP interface
  • structured summaries instead of raw table-heavy profile JSON
  • a way to work offline from saved profiles

mcp-samply provides that layer.

Tools

The server exposes eight MCP tools:

  • samply_doctor: verify whether the samply binary is available and report version / environment details
  • samply_record: run samply record --save-only and save a profile to disk
  • samply_summarize_profile: generate a compact summary of threads, hotspots, markers, and overall sample distribution
  • samply_inspect_thread: inspect one thread in detail, including representative stacks
  • samply_search_functions: search for functions or library names across the loaded profile
  • samply_breakdown_subsystems: group native functions by namespace prefix so agents can see which Rust / C++ subsystems dominate a profile
  • samply_focus_functions: recover the most common caller / callee contexts around a target function or namespace
  • samply_locate_symbols: map hot native symbols back to likely local source files so an agent can inspect implementation details

Presymbolication

By default, samply_record enables --unstable-presymbolicate.

That causes samply to emit a sidecar file such as:

profile.json.gz
profile.json.syms.json

mcp-samply reads that sidecar automatically and uses it to resolve native addresses into function names during offline analysis. This is critical for AI-driven performance work; without it, saved profiles often contain only raw addresses.

Use With Codex

Example MCP server config:

{
  "mcpServers": {
    "samply": {
      "command": "npx",
      "args": ["-y", "mcp-samply"],
      "env": {
        "MCP_SAMPLY_BIN": "samply"
      }
    }
  }
}

If samply is not on PATH, set MCP_SAMPLY_BIN to an absolute executable path.

You can still use the analysis tools on an existing profile file even when samply itself is not installed.

Typical Agent Workflow

  1. Call samply_doctor.
  2. Call samply_record with a command, PID, or all=true.
  3. Call samply_summarize_profile on the produced profile.
  4. Use samply_inspect_thread for the hottest thread.
  5. Use samply_search_functions for focused follow-up questions.
  6. Use samply_breakdown_subsystems to quantify native hotspots by crate / module prefix.
  7. Use samply_focus_functions to turn syscalls such as stat / read back into actionable upstream call paths.
  8. Use samply_locate_symbols to map the hottest native frames back to local source files before reading or patching code.

Local Development

npm install
npm run build
npm test

Run the MCP server locally:

npm run dev

Build output is published through the mcp-samply bin entry so the package can be launched with npx.

Publishing To npm

This repository includes a GitHub Actions workflow at .github/workflows/publish-npm.yml.

Before using it, add a repository secret named NPM_TOKEN with publish access to the mcp-samply package on npm.

The workflow can be triggered in two ways:

  1. Publish a GitHub Release whose tag matches the package version, for example v0.1.0.
  2. Run the workflow manually from the Actions tab with workflow_dispatch and provide the exact package version, for example 0.1.0.

On every publish run, the workflow will:

  1. Install dependencies with npm ci.
  2. Run npm run check.
  3. Run npm pack --dry-run.
  4. Publish with npm publish --provenance --access public.

Debugging The MCP Surface

This repository also includes a small local debug client so you can inspect the MCP surface and call tools without wiring up an external MCP host first.

List the exposed MCP surfaces:

npm run debug:mcp -- list-tools

The output includes:

  • tools: the currently registered MCP tools, including input and output schemas
  • prompts: prompt definitions, if any
  • resources: resource definitions, if any

Call a tool and print the full JSON result:

npm run debug:mcp -- call samply_doctor

Summarize one of the sample profiles committed in this repo:

npm run debug:mcp -- call samply_summarize_profile --args '{"profilePath":".samply/presym-smoke.json.gz"}'

Run symbol lookup against a local source tree:

npm run debug:mcp -- call samply_locate_symbols --args '{"roots":["/absolute/path/to/project"],"symbols":["rspack::Compiler::build"],"extensions":[".rs",".cc",".cpp"]}'

For larger payloads, store the tool input in a JSON file and use --args-file:

npm run debug:mcp -- call samply_record --args-file ./tool-args.json

Recommended manual debug loop:

  1. Run npm run debug:mcp -- list-tools to confirm the tool names and schemas.
  2. Call samply_doctor first to verify environment and binary resolution.
  3. Use samply_record or a saved profile.json(.gz) to generate real inputs.
  4. Run samply_summarize_profile, then drill into samply_inspect_thread, samply_search_functions, samply_breakdown_subsystems, and samply_focus_functions.
  5. Use samply_locate_symbols with your project root to confirm hotspot symbols map back to the files you expect.