tiny-stdio-mcp-server 0.1.3 → 0.1.5

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.
@@ -32,11 +32,30 @@ export function toContentBlocks(result) {
32
32
  return [convertSingleValue(result)];
33
33
  }
34
34
  function isContentBlock(value) {
35
- if (!("type" in value) || typeof value.type !== "string") {
35
+ if (!hasOwnProperty(value, "type") || typeof value.type !== "string") {
36
36
  return false;
37
37
  }
38
- return (value.type === "text" ||
39
- value.type === "image" ||
40
- value.type === "audio" ||
41
- value.type === "resource");
38
+ if (value.type === "text") {
39
+ return hasOwnProperty(value, "text") && typeof value.text === "string";
40
+ }
41
+ if (value.type === "image" || value.type === "audio") {
42
+ return hasOwnProperty(value, "data")
43
+ && typeof value.data === "string"
44
+ && hasOwnProperty(value, "mimeType")
45
+ && typeof value.mimeType === "string";
46
+ }
47
+ if (value.type !== "resource" || !hasOwnProperty(value, "resource")) {
48
+ return false;
49
+ }
50
+ const resource = value.resource;
51
+ return typeof resource === "object"
52
+ && resource !== null
53
+ && hasOwnProperty(resource, "uri")
54
+ && typeof resource.uri === "string"
55
+ && (!hasOwnProperty(resource, "mimeType") || typeof resource.mimeType === "string")
56
+ && ((hasOwnProperty(resource, "text") && typeof resource.text === "string")
57
+ || (hasOwnProperty(resource, "blob") && typeof resource.blob === "string"));
58
+ }
59
+ function hasOwnProperty(value, name) {
60
+ return Object.prototype.hasOwnProperty.call(value, name);
42
61
  }
package/dist/server.js CHANGED
@@ -574,55 +574,67 @@ function isCallToolResult(value) {
574
574
  return hasContentArray(value) && value.content.every(isContentItem);
575
575
  }
576
576
  function isGetPromptResult(value) {
577
- if (typeof value !== "object" || value === null || !("messages" in value)) {
577
+ if (typeof value !== "object" || value === null || !hasOwnProperty(value, "messages")) {
578
578
  return false;
579
579
  }
580
580
  return Array.isArray(value.messages)
581
581
  && value.messages.every((message) => typeof message === "object"
582
582
  && message !== null
583
- && "role" in message
583
+ && hasOwnProperty(message, "role")
584
584
  && (message.role === "user" || message.role === "assistant")
585
- && "content" in message
585
+ && hasOwnProperty(message, "content")
586
586
  && isPromptContentItem(message.content));
587
587
  }
588
588
  function isReadResourceResult(value) {
589
- if (typeof value !== "object" || value === null || !("contents" in value)) {
589
+ if (typeof value !== "object" || value === null || !hasOwnProperty(value, "contents")) {
590
590
  return false;
591
591
  }
592
592
  return Array.isArray(value.contents)
593
593
  && value.contents.every((content) => typeof content === "object"
594
594
  && content !== null
595
- && "uri" in content
595
+ && hasOwnProperty(content, "uri")
596
596
  && typeof content.uri === "string"
597
597
  && isValidUri(content.uri)
598
- && (("text" in content && typeof content.text === "string")
599
- || ("blob" in content && typeof content.blob === "string" && isBase64(content.blob))));
598
+ && ((hasOwnProperty(content, "text") && typeof content.text === "string")
599
+ || (hasOwnProperty(content, "blob") && typeof content.blob === "string" && isBase64(content.blob))));
600
600
  }
601
601
  function hasContentArray(value) {
602
- return typeof value === "object" && value !== null && "content" in value
602
+ return typeof value === "object" && value !== null && hasOwnProperty(value, "content")
603
603
  && Array.isArray(value.content);
604
604
  }
605
605
  function isContentItem(value) {
606
- if (typeof value !== "object" || value === null || !("type" in value)) {
606
+ if (typeof value !== "object" || value === null || !hasOwnProperty(value, "type")) {
607
607
  return false;
608
608
  }
609
609
  const block = value;
610
610
  if (block.type === "text") {
611
- return typeof block.text === "string";
611
+ return hasOwnProperty(block, "text") && typeof block.text === "string";
612
612
  }
613
613
  if (block.type === "image" || block.type === "audio") {
614
- return typeof block.data === "string" && isBase64(block.data) && typeof block.mimeType === "string";
614
+ return hasOwnProperty(block, "data")
615
+ && typeof block.data === "string"
616
+ && isBase64(block.data)
617
+ && hasOwnProperty(block, "mimeType")
618
+ && typeof block.mimeType === "string";
615
619
  }
616
620
  if (block.type === "resource_link") {
617
- return typeof block.uri === "string" && typeof block.name === "string";
621
+ return hasOwnProperty(block, "uri")
622
+ && typeof block.uri === "string"
623
+ && hasOwnProperty(block, "name")
624
+ && typeof block.name === "string";
618
625
  }
619
- if (block.type !== "resource" || typeof block.resource !== "object" || block.resource === null) {
626
+ if (block.type !== "resource"
627
+ || !hasOwnProperty(block, "resource")
628
+ || typeof block.resource !== "object"
629
+ || block.resource === null) {
620
630
  return false;
621
631
  }
622
632
  const resource = block.resource;
623
- return typeof resource.uri === "string"
624
- && (resource.mimeType === undefined || typeof resource.mimeType === "string")
625
- && (typeof resource.text === "string" || (typeof resource.blob === "string" && isBase64(resource.blob)));
633
+ return hasOwnProperty(resource, "uri")
634
+ && typeof resource.uri === "string"
635
+ && (!hasOwnProperty(resource, "mimeType") || typeof resource.mimeType === "string")
636
+ && ((hasOwnProperty(resource, "text") && typeof resource.text === "string")
637
+ || (hasOwnProperty(resource, "blob") && typeof resource.blob === "string" && isBase64(resource.blob)));
626
638
  }
627
639
  function isBase64(value) {
628
640
  if (value.length === 0) {
@@ -647,5 +659,8 @@ function isPromptContentItem(value) {
647
659
  if (!isContentItem(value)) {
648
660
  return false;
649
661
  }
650
- return !(typeof value === "object" && value !== null && "type" in value && value.type === "resource_link");
662
+ return !(typeof value === "object" && value !== null && hasOwnProperty(value, "type") && value.type === "resource_link");
663
+ }
664
+ function hasOwnProperty(value, name) {
665
+ return Object.prototype.hasOwnProperty.call(value, name);
651
666
  }
@@ -0,0 +1,7 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import type { Server } from "./server.js";
3
+ export interface TestPair {
4
+ client: Client;
5
+ cleanup: () => Promise<void>;
6
+ }
7
+ export declare function createTestPair(server: Server): Promise<TestPair>;
@@ -0,0 +1,20 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
3
+ export async function createTestPair(server) {
4
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
5
+ const client = new Client({
6
+ name: "test-client",
7
+ version: "1.0.0",
8
+ });
9
+ // Start server connection (runs in background)
10
+ const serverPromise = server.connectSDK(serverTransport);
11
+ // Connect client
12
+ await client.connect(clientTransport);
13
+ const cleanup = async () => {
14
+ await client.close();
15
+ await clientTransport.close();
16
+ await serverTransport.close();
17
+ await serverPromise;
18
+ };
19
+ return { client, cleanup };
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-stdio-mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Minimal MCP server over stdio with typed tools and rich content helpers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,8 +24,7 @@
24
24
  "prepublishOnly": "tsc"
25
25
  },
26
26
  "files": [
27
- "dist",
28
- "!dist/testing.*"
27
+ "dist"
29
28
  ],
30
29
  "engines": {
31
30
  "node": ">=20"