Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project are documented here. The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Reject non-array `tools` fields in static manifests before auditing, with an
error identifying the source file.

## [0.1.1] - 2026-08-06

### Changed
Expand Down
4 changes: 4 additions & 0 deletions src/static/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export function normalize(parsed: unknown, source: string): AuditTarget {
? { tools: parsed as ToolSpec[] }
: ((parsed as ManifestFile) ?? {});

if (manifest.tools != null && !Array.isArray(manifest.tools)) {
throw new Error(`Invalid manifest ${source}: tools must be an array.`);
}

const serverInfo = manifest.serverInfo ?? manifest.server ?? {};
const declaredHttp = manifest.transport === "http";

Expand Down
16 changes: 16 additions & 0 deletions test/static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ describe("loadManifest", () => {
expect(target.transport).toBe("static");
});

it.each(["MCP001", { name: "read_file" }, 42, true])(
"rejects a non-array tools field: %j",
(tools) => {
expect(() => normalize({ tools }, "invalid-tools.json")).toThrow(
"Invalid manifest invalid-tools.json: tools must be an array.",
);
},
);

it.each([{}, { tools: null }, { tools: [] }])(
"keeps an absent or empty tool list valid: %j",
(manifest) => {
expect(normalize(manifest, "empty.json").tools).toEqual([]);
},
);

it("rejects a missing manifest file", async () => {
await expect(loadManifest(resolve(root, "does-not-exist.json"))).rejects.toBeTruthy();
});
Expand Down
Loading