Skip to content

Commit 92c1353

Browse files
authored
Merge branch 'main' into fix/time-docker-local-timezone-expansion
2 parents 72bb679 + 2e3e4c7 commit 92c1353

31 files changed

Lines changed: 901 additions & 154 deletions

‎.github/workflows/readme-pr-check.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: README PR Check
22

33
on:
4-
pull_request:
4+
# pull_request_target, not pull_request: fork PRs get a read-only token under
5+
# pull_request, so the label and comment calls fail with 403. This job only
6+
# calls the API and never checks out PR code, so the write token is safe.
7+
pull_request_target:
58
types: [opened]
69
paths:
710
- 'README.md'
@@ -10,7 +13,7 @@ on:
1013

1114
jobs:
1215
check-readme-only:
13-
if: github.event_name == 'pull_request'
16+
if: github.event_name == 'pull_request_target'
1417
runs-on: ubuntu-latest
1518
permissions:
1619
contents: read

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ These servers aim to demonstrate MCP features and the official SDKs.
3939
The following reference servers are now archived and can be found at [servers-archived](https://github.com/modelcontextprotocol/servers-archived).
4040

4141
- **[AWS KB Retrieval](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/aws-kb-retrieval-server)** - Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
42-
- **[Brave Search](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/brave-search)** - Web and local search using Brave's Search API. Has been replaced by the [official server](https://github.com/brave/brave-search-mcp-server).
42+
- **[Brave Search](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/brave-search)** - Web and local search using Brave's Search API. Has been replaced by the [official server](https://github.com/brave/brave-search-mcp-server) ([`@brave/brave-search-mcp-server`](https://www.npmjs.com/package/@brave/brave-search-mcp-server)).
4343
- **[EverArt](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/everart)** - AI image generation using various models.
4444
- **[GitHub](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/github)** - Repository management, file operations, and GitHub API integration.
4545
- **[GitLab](https://github.com/modelcontextprotocol/servers-archived/tree/main/src/gitlab)** - GitLab API, enabling project management.

‎src/everything/resources/subscriptions.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ export const setSubscriptionHandlers = (server: McpServer) => {
9999
/**
100100
* Sends simulated resource update notifications to the subscribed client.
101101
*
102-
* This function iterates through all resource URIs stored in the subscriptions
103-
* and checks if the specified session ID is subscribed to them. If so, it sends
104-
* a notification through the provided server. If the session ID is no longer valid
105-
* (disconnected), it removes the session ID from the list of subscribers.
102+
* Iterates the URIs in `subscriptions` and emits a
103+
* `notifications/resources/updated` notification for each URI the given
104+
* sessionId is subscribed to.
106105
*
107106
* @param {McpServer} server - The server instance used to send notifications.
108107
* @param {string | undefined} sessionId - The session ID of the client to check for subscriptions.
@@ -122,8 +121,6 @@ const sendSimulatedResourceUpdates = async (
122121
method: "notifications/resources/updated",
123122
params: { uri },
124123
});
125-
} else {
126-
subscribers.delete(sessionId); // subscriber has disconnected
127124
}
128125
}
129126
};

‎src/everything/resources/templates.ts‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,26 @@ export const blobResourceUri = (resourceId: number) =>
127127
new URL(`${blobUriBase}/${resourceId}`);
128128

129129
/**
130-
* Parses the resource identifier from the provided URI and validates it
131-
* against the given variables. Throws an error if the URI corresponds
132-
* to an unknown resource or if the resource identifier is invalid.
130+
* Parses the resource identifier from the provided variables and validates
131+
* that it is a positive integer.
133132
*
134-
* @param {URL} uri - The URI of the resource to be parsed.
135-
* @param {Record<string, unknown>} variables - A record containing context-specific variables that include the resourceId.
136-
* @returns {number} The parsed and validated resource identifier as an integer.
137-
* @throws {Error} Throws an error if the URI matches unsupported base URIs or if the resourceId is invalid.
133+
* The SDK only routes URIs that match the registered template to the
134+
* resource handler, so by the time we get here the URI prefix is already
135+
* known to be one of `textUriBase` / `blobUriBase`. Only the resourceId
136+
* variable still needs validating.
137+
*
138+
* @param {URL} uri - The URI of the resource (used in the error message).
139+
* @param {Record<string, unknown>} variables - Context variables including resourceId.
140+
* @returns {number} The parsed and validated resource identifier as a positive integer.
141+
* @throws {Error} If the resourceId is not a finite positive integer.
138142
*/
139143
const parseResourceId = (uri: URL, variables: Record<string, unknown>) => {
140-
const uriError = `Unknown resource: ${uri.toString()}`;
141-
if (
142-
uri.toString().startsWith(textUriBase) &&
143-
uri.toString().startsWith(blobUriBase)
144-
) {
145-
throw new Error(uriError);
146-
} else {
147-
const idxStr = String((variables as any).resourceId ?? "");
148-
const idx = Number(idxStr);
149-
if (Number.isFinite(idx) && Number.isInteger(idx) && idx > 0) {
150-
return idx;
151-
} else {
152-
throw new Error(uriError);
153-
}
144+
const idxStr = String((variables as any).resourceId ?? "");
145+
const idx = Number(idxStr);
146+
if (Number.isFinite(idx) && Number.isInteger(idx) && idx > 0) {
147+
return idx;
154148
}
149+
throw new Error(`Unknown resource: ${uri.toString()}`);
155150
};
156151

157152
/**

‎src/fetch/Dockerfile‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ ENV UV_COMPILE_BYTECODE=1
1111
ENV UV_LINK_MODE=copy
1212

1313
# Install the project's dependencies using the lockfile and settings
14+
COPY uv.lock pyproject.toml ./
1415
RUN --mount=type=cache,target=/root/.cache/uv \
15-
--mount=type=bind,source=uv.lock,target=uv.lock \
16-
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
1716
uv sync --locked --no-install-project --no-dev --no-editable
1817

1918
# Then, add the rest of the project source code and install it
@@ -27,6 +26,10 @@ FROM python:3.12-slim-bookworm
2726
WORKDIR /app
2827

2928
COPY --from=uv /root/.local /root/.local
29+
30+
RUN if ! id -u app >/dev/null 2>&1; then \
31+
useradd -rUM -s /usr/sbin/nologin app; \
32+
fi
3033
COPY --from=uv --chown=app:app /app/.venv /app/.venv
3134

3235
# Place executables in the environment at the front of the path

‎src/fetch/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A Model Context Protocol server that provides web content fetching capabilities.
66

77
Source: https://github.com/modelcontextprotocol/servers/tree/main/src/fetch
88

9+
Requires MCP Python SDK 1.x (`mcp>=1.29.0,<2`). SDK 2.0 renamed APIs this server uses. The port to v2 is in progress.
10+
911
> [!CAUTION]
1012
> This server can access local/internal IP addresses and may represent a security risk. Exercise caution when using this MCP server to ensure this does not expose any sensitive data.
1113

‎src/fetch/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ classifiers = [
1818
dependencies = [
1919
"httpx>=0.27",
2020
"markdownify>=0.13.1",
21-
"mcp>=1.1.3",
21+
"mcp>=1.29.0,<2",
2222
"protego>=0.3.1",
2323
"pydantic>=2.0.0",
2424
"readabilipy>=0.2.0",

‎src/fetch/uv.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2+
import * as fs from 'fs/promises';
3+
import * as path from 'path';
4+
import * as os from 'os';
5+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
6+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
7+
8+
describe('directory_tree MCP SDK regression', () => {
9+
let client: Client;
10+
let transport: StdioClientTransport;
11+
let testDir: string;
12+
13+
beforeEach(async () => {
14+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'mcp-fs-tree-'));
15+
testDir = await fs.realpath(tmp);
16+
17+
await fs.writeFile(path.join(testDir, 'root.txt'), 'root');
18+
await fs.mkdir(path.join(testDir, 'nested'));
19+
await fs.writeFile(path.join(testDir, 'nested', 'child.txt'), 'child');
20+
21+
const serverPath = path.resolve(__dirname, '../dist/index.js');
22+
transport = new StdioClientTransport({
23+
command: 'node',
24+
args: [serverPath, testDir],
25+
});
26+
27+
client = new Client(
28+
{ name: 'directory-tree-regression-test', version: '1.0.0' },
29+
{ capabilities: {} },
30+
);
31+
32+
await client.connect(transport);
33+
});
34+
35+
afterEach(async () => {
36+
await client?.close();
37+
await fs.rm(testDir, { recursive: true, force: true });
38+
});
39+
40+
it('returns structuredContent.content as a string (not an array) when called via MCP SDK', async () => {
41+
const result = await client.callTool({
42+
name: 'directory_tree',
43+
arguments: { path: testDir },
44+
});
45+
46+
// Regression test for issues where structuredContent was returned as an array,
47+
// which causes MCP SDK validation to throw -32602 (invalid structured content).
48+
const structured = result.structuredContent as { content: unknown };
49+
expect(structured).toBeDefined();
50+
expect(typeof structured.content).toBe('string');
51+
expect(Array.isArray(structured.content)).toBe(false);
52+
53+
const parsed = JSON.parse(structured.content as string);
54+
expect(Array.isArray(parsed)).toBe(true);
55+
expect(parsed.length).toBeGreaterThan(0);
56+
});
57+
});

0 commit comments

Comments
 (0)