opentel-mcp 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Fixed
6
+
7
+ - `src/index.d.ts` re-exported values (`computeFingerprint`,
8
+ `toSpanAttributes`, `ATTRIBUTE_KEYS`, `METRIC_SAFE_ATTRIBUTES`,
9
+ `DEFAULT_CLASSIFIERS`, `DEFAULT_PRICING`, `defaultExtractor`,
10
+ `calculateCost`) from six `.js` modules that had no corresponding `.d.ts`
11
+ file, so any consumer with `strict`/`noImplicitAny` got a TS7016 error
12
+ just from importing the package. Added `src/fingerprint/compose.d.ts`,
13
+ `src/fingerprint/attributes.d.ts`, `src/fingerprint/classify/index.d.ts`,
14
+ `src/cost/pricing.d.ts`, `src/cost/extractor.d.ts`, and
15
+ `src/cost/calculator.d.ts`. Pre-existing since v0.4.0 (fingerprinting) and
16
+ v0.5.0 (cost tracking) — first caught verifying the v0.6.0 published
17
+ tarball.
18
+
3
19
  ## 0.6.0
4
20
 
5
21
  ### Added — Agent Thrash Detection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentel-mcp",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "One-line OpenTelemetry instrumentation for Model Context Protocol (MCP) servers",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -25,9 +25,11 @@
25
25
  "test:watch": "vitest",
26
26
  "test:coverage": "vitest run --coverage",
27
27
  "typecheck": "tsc --noEmit",
28
+ "verify:tarball": "node scripts/verify-tarball.js",
28
29
  "bench": "vitest bench --run",
29
30
  "prepack": "node scripts/strip-workspaces.js",
30
- "postpack": "node scripts/restore-workspaces.js"
31
+ "postpack": "node scripts/restore-workspaces.js",
32
+ "prepublishOnly": "npm run verify:tarball"
31
33
  },
32
34
  "keywords": [
33
35
  "mcp",
@@ -0,0 +1,13 @@
1
+ import type { PricingTable } from './types.d.ts';
2
+
3
+ /**
4
+ * Calculates the USD cost of a request from its input/output token counts, a
5
+ * model name, and a pricing table. Never throws: an unrecognized model or an
6
+ * invalid token count resolves to `null` rather than an exception.
7
+ */
8
+ export function calculateCost(
9
+ inputTokens: number,
10
+ outputTokens: number,
11
+ model: string,
12
+ pricingTable: PricingTable,
13
+ ): number | null;
@@ -0,0 +1,8 @@
1
+ import type { UsageExtractor } from './types.d.ts';
2
+
3
+ /**
4
+ * Default {@link UsageExtractor}. Recognizes Anthropic/OpenAI/Bedrock usage
5
+ * field conventions, JSON-in-text content, and the MCP `_meta.usage`
6
+ * extension point. Never throws — returns `null` for any unrecognized shape.
7
+ */
8
+ export const defaultExtractor: UsageExtractor;
@@ -0,0 +1,8 @@
1
+ import type { PricingTable } from './types.d.ts';
2
+
3
+ /**
4
+ * Static per-model token pricing used to estimate MCP tool-call cost, in USD
5
+ * per 1M tokens. A best-effort snapshot — callers who need accurate cost
6
+ * attribution should supply their own {@link PricingTable}.
7
+ */
8
+ export const DEFAULT_PRICING: PricingTable;
@@ -0,0 +1,20 @@
1
+ import type { Attributes } from '@opentelemetry/api';
2
+ import type { FingerprintResult } from './types.d.ts';
3
+
4
+ /** The `mcp.failure.*` OpenTelemetry span attribute keys. */
5
+ export const ATTRIBUTE_KEYS: Readonly<
6
+ Record<'FINGERPRINT' | 'SIGNATURE' | 'CATEGORY' | 'ORIGIN' | 'ERROR_CLASS', string>
7
+ >;
8
+
9
+ /**
10
+ * Attribute keys safe to attach to metric labels — `category` and `origin`
11
+ * only; everything else in {@link ATTRIBUTE_KEYS} is unbounded or
12
+ * medium-cardinality and must stay span-only.
13
+ */
14
+ export const METRIC_SAFE_ATTRIBUTES: readonly string[];
15
+
16
+ /**
17
+ * Builds the span attributes for a fingerprinted failure. Never throws —
18
+ * returns `{}` if `result` is malformed in any way.
19
+ */
20
+ export function toSpanAttributes(result: FingerprintResult): Attributes;
@@ -0,0 +1,18 @@
1
+ import type { Classifier, FailureCategory, FingerprintContext } from '../types.d.ts';
2
+
3
+ /**
4
+ * The ordered classifier registry: each classifier gets first refusal on an
5
+ * error, in order, and the first non-null category wins. `internal` is a
6
+ * catch-all that always matches, so it stays last.
7
+ */
8
+ export const DEFAULT_CLASSIFIERS: readonly Classifier[];
9
+
10
+ /**
11
+ * Runs `classifiers` against `err` in order, returning the first non-null
12
+ * category. Falls back to `"unknown"` if every classifier returns null.
13
+ */
14
+ export function runClassifiers(
15
+ err: unknown,
16
+ ctx: FingerprintContext,
17
+ classifiers?: readonly Classifier[],
18
+ ): FailureCategory;
@@ -0,0 +1,11 @@
1
+ import type { ComputeFingerprintOptions, FingerprintContext, FingerprintResult } from './types.d.ts';
2
+
3
+ /**
4
+ * Computes a stable identity fingerprint for a failure. Never throws — falls
5
+ * back to a well-known "unfingerprintable" result on any unexpected shape.
6
+ */
7
+ export function computeFingerprint(
8
+ err: unknown,
9
+ ctx: FingerprintContext,
10
+ opts?: ComputeFingerprintOptions,
11
+ ): FingerprintResult;