fastmcp 1.19.1 → 1.19.2

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/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glama/fastmcp",
3
- "version": "1.19.1",
3
+ "version": "1.19.2",
4
4
  "exports": "./src/FastMCP.ts",
5
5
  "include": ["src/FastMCP.ts", "src/bin/fastmcp.ts"]
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastmcp",
3
- "version": "1.19.1",
3
+ "version": "1.19.2",
4
4
  "main": "dist/FastMCP.js",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -25,7 +25,7 @@
25
25
  "execa": "^9.5.2",
26
26
  "file-type": "^20.3.0",
27
27
  "fuse.js": "^7.1.0",
28
- "mcp-proxy": "^2.5.0",
28
+ "mcp-proxy": "^2.5.1",
29
29
  "strict-event-emitter-types": "^2.0.0",
30
30
  "uri-templates": "^0.2.0",
31
31
  "yargs": "^17.7.2",
@@ -1369,3 +1369,115 @@ test("server remains usable after InvalidParams error", async () => {
1369
1369
  },
1370
1370
  });
1371
1371
  });
1372
+
1373
+ test("allows new clients to connect after a client disconnects", async () => {
1374
+ const port = await getRandomPort();
1375
+
1376
+ const server = new FastMCP({
1377
+ name: "Test",
1378
+ version: "1.0.0",
1379
+ });
1380
+
1381
+ server.addTool({
1382
+ name: "add",
1383
+ description: "Add two numbers",
1384
+ parameters: z.object({
1385
+ a: z.number(),
1386
+ b: z.number(),
1387
+ }),
1388
+ execute: async (args) => {
1389
+ return String(args.a + args.b);
1390
+ },
1391
+ });
1392
+
1393
+ await server.start({
1394
+ transportType: "sse",
1395
+ sse: {
1396
+ endpoint: "/sse",
1397
+ port,
1398
+ },
1399
+ });
1400
+
1401
+ const client1 = new Client(
1402
+ {
1403
+ name: "example-client",
1404
+ version: "1.0.0",
1405
+ },
1406
+ {
1407
+ capabilities: {},
1408
+ },
1409
+ );
1410
+
1411
+ const transport1 = new SSEClientTransport(
1412
+ new URL(`http://localhost:${port}/sse`),
1413
+ );
1414
+
1415
+ await client1.connect(transport1);
1416
+
1417
+ expect(
1418
+ await client1.callTool({
1419
+ name: "add",
1420
+ arguments: {
1421
+ a: 1,
1422
+ b: 2,
1423
+ },
1424
+ }),
1425
+ ).toEqual({
1426
+ content: [{ type: "text", text: "3" }],
1427
+ });
1428
+
1429
+ await client1.close();
1430
+
1431
+ const client2 = new Client(
1432
+ {
1433
+ name: "example-client",
1434
+ version: "1.0.0",
1435
+ },
1436
+ {
1437
+ capabilities: {},
1438
+ },
1439
+ );
1440
+
1441
+ const transport2 = new SSEClientTransport(
1442
+ new URL(`http://localhost:${port}/sse`),
1443
+ );
1444
+
1445
+ await client2.connect(transport2);
1446
+
1447
+ expect(
1448
+ await client2.callTool({
1449
+ name: "add",
1450
+ arguments: {
1451
+ a: 1,
1452
+ b: 2,
1453
+ },
1454
+ }),
1455
+ ).toEqual({
1456
+ content: [{ type: "text", text: "3" }],
1457
+ });
1458
+
1459
+ await client2.close();
1460
+
1461
+ await server.stop();
1462
+ });
1463
+
1464
+ test("able to close server immediately after starting it", async () => {
1465
+ const port = await getRandomPort();
1466
+
1467
+ const server = new FastMCP({
1468
+ name: "Test",
1469
+ version: "1.0.0",
1470
+ });
1471
+
1472
+ await server.start({
1473
+ transportType: "sse",
1474
+ sse: {
1475
+ endpoint: "/sse",
1476
+ port,
1477
+ },
1478
+ });
1479
+
1480
+ // We were previously not waiting for the server to start.
1481
+ // Therefore, this would have caused error 'Server is not running.'.
1482
+ await server.stop();
1483
+ });