open-index/open-npm huggingface dataset:
npm package: @mcp-layer/error
Description: Documented runtime errors for mcp-layer packages.
Latest version: 0.2.1

# @mcp-layer/error

Custom error class for mcp-layer packages.

The implementation follows the same mechanics as `@bento/error`:

- deterministic short hashtag from `name + method + message`,
- source context in the message (`@scope/package(method)`),
- generated docs URL tied to the thrown error identity,
- support for named placeholder interpolation via `vars`,
- passthrough custom fields on the error instance.

No support-channel line is appended.

## Table of Contents

- [Installation](#installation)
- [API Reference](#api-reference)
- [Example](#example)

## Installation

```sh
pnpm add @mcp-layer/error
```

## API Reference

### `new LayerError(args)`

```js
new LayerError({
  name: 'manager',
  method: 'identity',
  message: 'Authorization header is required.',
  vars: {},
  docs: 'github.com/3rd-Eden/mcp-layer/tree/main/packages',
  scope: '@mcp-layer',
  ...customFields
});
```

Required:

- `name`
- `method`
- `message`

Optional:

- `vars` for named replacement in `message` (for example `{ server: 'demo' }` for `Server "{server}" was not found.`)
- `args` for legacy positional `%s` replacement in `message`
- `docs` base path override
- `scope` override
- any other custom fields (`status`, `cause`, etc), copied to the error object

### `hashtag(message)`

Generates the short deterministic reference hash.

### `docs(args)`

Builds the package README error URL:

`https://<docs>/<package>/README.md#error-<hash>`

## Example

This example shows the intended throw pattern. It matters because the error always contains package/method context and a deterministic URL for remediation.

Expected behavior: message contains `@mcp-layer/manager(identity)` and a URL to the manager README error section.

```js
import { LayerError } from '@mcp-layer/error';

throw new LayerError({
  name: 'manager',
  method: 'identity',
  message: 'Authorization header is required.'
});
```

## License

MIT
npm package: @mcp-layer/session
Description: Shared MCP session wrapper used by connect and attach.
Latest version: 1.0.1

# @mcp-layer/session

`@mcp-layer/session` provides the shared Session class used by both `@mcp-layer/connect` and `@mcp-layer/attach`. A Session is the handle you pass around when layering new functionality on top of an MCP server.


Multiple packages return the same connected handle. To avoid duplication and drift, the Session class lives here and is re-exported by other packages.

## Table of Contents

- [Usage](#usage)
- [Session shape](#session-shape)
- [Lifecycle](#lifecycle)
- [Common usage pattern](#common-usage-pattern)

## Usage

```js
import { Session } from '@mcp-layer/session';
```

Most users do not construct Session manually. Instead, create one via:
- `@mcp-layer/connect` (remote/stdio transport)
- `@mcp-layer/attach` (in-process server instance)

## Session shape

A Session instance contains:
- `client` - MCP SDK client
- `transport` - the active transport (stdio or in-memory)
- `info` - client identity
- `name` - logical server name
- `source` - source string (config path or `in-memory`)
- `entry` - server entry when available (otherwise `null`)

## Lifecycle

Always call `session.close()` when you are done to close the client and transport.

## Common usage pattern

```js
import { load } from '@mcp-layer/config';
import { connect } from '@mcp-layer/connect';

const config = await load(undefined, process.cwd());
const session = await connect(config, 'demo');

try {
  const tools = await session.client.listTools({});
  console.log(tools.tools.map((tool) => tool.name));
} finally {
  await session.close();
}
```

## License

MIT