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

mcpscope-engine

v0.1.7

Published

Embeddable chat/session engine for MCP: agent loop, MCP tool calling, local-first LM providers, durable node:sqlite sessions, and fine-grained transparency events. Zero runtime dependencies beyond zod.

Readme

mcpscope-engine

The embeddable chat/session engine extracted from mcpscope: an in-process agent runtime for Node.js/TypeScript apps that need MCP tool calling against local-first models, with durable sessions and fine-grained transparency — and almost no dependencies.

  • Agent loop — model turn → MCP tool calls → repeat, bounded by maxToolRounds.
  • MCP client over streamable-HTTP/SSE with bearer/basic auth (hand-rolled JSON-RPC, zero SDK).
  • Local-first providers — OpenAI-compatible endpoints, LM Studio, Ollama, OpenRouter.
  • Durable sessions in Node's built-in node:sqlite (:memory: supported), with crash recovery.
  • Transparency — token deltas, per-part token attribution, context-window state, full trace bundles.
  • One runtime dependency: zod. No Fastify, no MCP SDK, no native modules, no telemetry.

Requires Node.js >= 24 (for a stable node:sqlite). Apache-2.0.

Install

npm install mcpscope-engine

Quick start

import { createEngine } from 'mcpscope-engine'

const engine = await createEngine({
  storage: { sqlitePath: '/var/lib/my-app/engine.db' }, // or { memory: true }
  config: {                                             // programmatic — no file needed
    lmConnections: [
      { id: 'lmstudio', name: 'LM Studio', providerType: 'lmstudio',
        baseUrl: 'http://127.0.0.1:1234/v1', apiKey: null },
    ],
    modelConfigs: [
      { id: 'qwen', connectionId: 'lmstudio', /* … model settings … */ } as ModelConfig,
    ],
    sessionCreationDefaults: { defaultModelConfigId: 'qwen', updatedAt: Date.now() },
  },
  maxToolRounds: 8,
})

// Stream every turn/tool/token event to your own transport (WebSocket, SSE, …).
const stop = engine.onEvent((event) => myTransport.publish(event))

const { session } = await engine.createSession({ title: 'Support chat' })
await engine.send({ session_id: session.id, prompt: 'What is the weather in Oslo?' })

const trace = engine.getTrace(session.id) // transcript + context views + per-part tokens
stop()
engine.close()

API

createEngine(options) assembles the runtime (database, config store, scheduler, default LM/MCP gateways) and returns an Engine:

| Member | Purpose | |---|---| | createSession(input) | Create a session (title, optional model/MCP/compaction). | | send(input) | Enqueue a user turn ({ session_id, prompt, wait? }). | | status(input) | Lifecycle + latest turn for a session. | | listSessions() | All sessions, newest first. | | inspect(input) | Resolve any hierarchical ID (ABCD, ABCD.1T, ABCD.1T.2.3-R). | | getTrace(sessionId) | Full trace bundle, or null if unknown. | | onEvent(listener) | Subscribe to scheduler/turn events; returns an unsubscribe fn. | | abortActive() | Abort the active job, if any. | | close() | Close the database. | | config | The instance-owned ConfigStore (upsert LM connections, models, MCP profiles at runtime). | | opCtx, scheduler | The assembled context and scheduler, for advanced/custom operations. |

Options

  • storage{ sqlitePath: string } or { memory: true }.
  • configPath? — load a mcpscope.config.json; omit for a purely programmatic, file-less engine.
  • config? — programmatic LM connections / model configs / MCP profiles / defaults, applied after any configPath.
  • maxToolRounds? — model↔tool rounds per turn (default: engine default).
  • logger?{ error(data, msg) } for background errors.
  • dependencies? — override the LM/MCP gateways (e.g. scripted models in tests).

What the engine does not do

It has no user or auth concept — access control and user↔session mapping are the embedder's job. It exposes no HTTP surface; you own the transport and fan events out to your own clients. Benchmarking, evaluation, and analysis live in the mcpscope workbench, not here.

Full guide

This README is the summary. The complete integration tutorial — configuration, the event/transparency model, a full Express example, testing, and a coding-agent quick reference — is in EMBEDDING.md.

License

Apache-2.0. See LICENSE and NOTICE.