tiny-http-mcp-server 0.1.20 → 0.1.21

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.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.20",
21
+ "version": "0.1.21",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -36,6 +36,8 @@ Legacy SSE mode opens a GET stream and posts messages to the endpoint announced
36
36
  by the server. Announced endpoints must remain on the original origin without
37
37
  embedded credentials or fragments; endpoint changes close the connection.
38
38
  Both transports accept the same headers, OAuth provider and response limits.
39
+ HTTP failures expose `HttpTransportError.status` and `.method`, so callers can
40
+ make transport decisions without parsing error messages.
39
41
 
40
42
  ## OAuth HTTP support
41
43
 
@@ -583,6 +583,11 @@ interface StdioTransportOptions {
583
583
  spawn?: StdioSpawn;
584
584
  }
585
585
  type HttpTransportFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
586
+ declare class HttpTransportError extends Error {
587
+ readonly status: number;
588
+ readonly method: "GET" | "POST" | "DELETE";
589
+ constructor(message: string, status: number, method: "GET" | "POST" | "DELETE");
590
+ }
586
591
  interface HttpTransportOptions {
587
592
  url: string;
588
593
  /** Legacy SSE uses a GET stream that announces the RPC POST endpoint. */
@@ -743,5 +748,5 @@ declare class JsonRpcMessageLayer {
743
748
  private handleCancellationNotification;
744
749
  }
745
750
 
746
- export { ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, JsonRpcMessageLayer, McpClient, McpError, OAuthMetadataDiscovery, StdioTransport, createInMemoryTransportPair, createSdkTestPair, createTestPair, discoverOAuthMetadata, fetchMcpResponse };
751
+ export { ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, HttpTransportError, JsonRpcMessageLayer, McpClient, McpError, OAuthMetadataDiscovery, StdioTransport, createInMemoryTransportPair, createSdkTestPair, createTestPair, discoverOAuthMetadata, fetchMcpResponse };
747
752
  export type { AudioContent, BlobResourceContents, CacheableResultMetadata, CallToolOptions, CallToolParams, CallToolResult, ClientCapabilities, CompleteArgument, CompleteParams, CompleteResult, Completion, ConnectResult, ContentItem, CreateMessageParams, CreateMessageResult, ElicitationParams, ElicitationResult, EmbeddedResource, GetPromptParams, GetPromptResult, HttpTransportFetch, HttpTransportOptions, ImageContent, InMemoryTransportPair, IncludeContext, InitializeParams, InitializeResult, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcRequestOptions, JsonRpcResponse, JsonRpcSuccessResponse, LogLevel, LogMessage, McpClientConnection, McpClientOptions, McpRequestContext, McpSubscription, McpTransport, McpTransportClosedEvent, ModelHint, ModelPreferences, NotificationFilter, OAuthAuthorizationServerMetadata, OAuthClientProvider, OAuthClientProviderOptions, OAuthDiscoveryCache, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthSessionStore, OAuthUnauthorizedChallenge, PaginatedParams, PaginatedResult, ProgressParams, ProgressToken, PromptMessage, PromptReference, ReadResourceParams, RequestId, ResourceContents, ResourceReference, ResultMetadata, Root, SamplingContent, SamplingMessage, SdkTestPair, ServerCapabilities, StdioSpawn, StdioTransportOptions, StoredOAuthSession, SubscriptionOptions, TextContent, TextResourceContents, Tool, ToolResultContent, ToolUseContent };
@@ -6505,6 +6505,16 @@ async function createTestPair(server, createClient) {
6505
6505
  };
6506
6506
  return { client, cleanup };
6507
6507
  }
6508
+ var HttpTransportError = class extends Error {
6509
+ constructor(message, status, method) {
6510
+ super(message);
6511
+ this.status = status;
6512
+ this.method = method;
6513
+ this.name = "HttpTransportError";
6514
+ }
6515
+ status;
6516
+ method;
6517
+ };
6508
6518
  function defaultStdioSpawn(command, args, options) {
6509
6519
  return spawn2(command, args, options);
6510
6520
  }
@@ -6819,7 +6829,7 @@ var HttpTransport = class {
6819
6829
  if (hasSessionId && response.status === 404) {
6820
6830
  void response.body?.cancel().catch(() => void 0);
6821
6831
  this.sessionId = void 0;
6822
- this.dispose(new Error("HTTP transport session expired (404 response)"));
6832
+ this.dispose(new HttpTransportError("HTTP transport session expired (404 response)", 404, "POST"));
6823
6833
  return;
6824
6834
  }
6825
6835
  if (await this.throwForPostHttpError(
@@ -6958,7 +6968,7 @@ var HttpTransport = class {
6958
6968
  const responseBody = (await readBoundedResponseText(response, this.maxResponseBytes, this.openResponseReaders, signal)).trim();
6959
6969
  const statusDescriptor = `${response.status} ${response.statusText}`.trim();
6960
6970
  const message = responseBody.length === 0 ? `HTTP transport DELETE failed (${statusDescriptor})` : `HTTP transport DELETE failed (${statusDescriptor}): ${responseBody}`;
6961
- throw new Error(message);
6971
+ throw new HttpTransportError(message, response.status, "DELETE");
6962
6972
  }
6963
6973
  async consumeGetSseStream() {
6964
6974
  const response = await this.fetchWithOAuthRetry({
@@ -6971,18 +6981,19 @@ var HttpTransport = class {
6971
6981
  }
6972
6982
  if (response.status === 405) {
6973
6983
  void response.body?.cancel().catch(() => void 0);
6984
+ if (this.mode === "sse") throw new HttpTransportError("Legacy SSE GET failed (405)", 405, "GET");
6974
6985
  throw new HttpTransportGetSseNotSupportedError();
6975
6986
  }
6976
6987
  if (response.status === 404) {
6977
6988
  void response.body?.cancel().catch(() => void 0);
6978
6989
  this.sessionId = void 0;
6979
- throw new Error("HTTP transport session expired (GET 404 response)");
6990
+ throw new HttpTransportError("HTTP transport session expired (GET 404 response)", 404, "GET");
6980
6991
  }
6981
6992
  if (!response.ok) {
6982
6993
  const responseBody = (await readBoundedResponseText(response, this.maxResponseBytes, this.openResponseReaders)).trim();
6983
6994
  const statusDescriptor = `${response.status} ${response.statusText}`.trim();
6984
6995
  const message = responseBody.length === 0 ? `HTTP transport GET failed (${statusDescriptor})` : `HTTP transport GET failed (${statusDescriptor}): ${responseBody}`;
6985
- throw new Error(message);
6996
+ throw new HttpTransportError(message, response.status, "GET");
6986
6997
  }
6987
6998
  const contentType = response.headers.get("Content-Type");
6988
6999
  if (contentType === null) {
@@ -7043,7 +7054,7 @@ var HttpTransport = class {
7043
7054
  }
7044
7055
  const statusDescriptor = `${response.status} ${response.statusText}`.trim();
7045
7056
  const message = responseBody.length === 0 ? `HTTP transport POST failed (${statusDescriptor})` : `HTTP transport POST failed (${statusDescriptor}): ${responseBody}`;
7046
- throw new Error(message);
7057
+ throw new HttpTransportError(message, response.status, "POST");
7047
7058
  }
7048
7059
  async maybeHandleUnauthorizedResponse(response) {
7049
7060
  if (response.status !== 401 || this.oauthProvider === void 0) {
@@ -8123,6 +8134,7 @@ export {
8123
8134
  ERROR_METHOD_NOT_FOUND,
8124
8135
  ERROR_PARSE,
8125
8136
  HttpTransport,
8137
+ HttpTransportError,
8126
8138
  JsonRpcMessageLayer,
8127
8139
  McpClient,
8128
8140
  McpError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",