tiny-http-mcp-server 0.1.4 → 0.1.6
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/dist/composition.json +1 -1
- package/dist/express-middleware.js +1 -1
- package/dist/http-server.d.ts +2 -0
- package/dist/http-server.js +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/package.json +1 -1
package/dist/composition.json
CHANGED
|
@@ -40,7 +40,7 @@ export function createProtectedResourceMetadataRouter(options) {
|
|
|
40
40
|
if (path === "/") {
|
|
41
41
|
return [PROTECTED_RESOURCE_METADATA_PATH];
|
|
42
42
|
}
|
|
43
|
-
return [`${PROTECTED_RESOURCE_METADATA_PATH}${path}`];
|
|
43
|
+
return [PROTECTED_RESOURCE_METADATA_PATH, `${PROTECTED_RESOURCE_METADATA_PATH}${path}`];
|
|
44
44
|
})();
|
|
45
45
|
return (req, res, next) => {
|
|
46
46
|
if (req.method !== "GET" || !metadataPaths.includes(req.path)) {
|
package/dist/http-server.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export interface TinyHttpMcpServerOAuthOptions extends ProtectedResourceMetadata
|
|
|
14
14
|
}
|
|
15
15
|
export type HttpTransportOptions = ServerOptions & StreamableHttpTransportOptions & {
|
|
16
16
|
oauth?: TinyHttpMcpServerOAuthOptions;
|
|
17
|
+
requestHandler?: HttpAdditionalRequestHandler;
|
|
17
18
|
};
|
|
19
|
+
export type HttpAdditionalRequestHandler = (request: IncomingMessage, response: ServerResponse) => boolean | Promise<boolean>;
|
|
18
20
|
export interface HttpListenOptions {
|
|
19
21
|
port?: number;
|
|
20
22
|
hostname?: string;
|
package/dist/http-server.js
CHANGED
|
@@ -19,7 +19,7 @@ function getProtectedResourceMetadataPaths(path) {
|
|
|
19
19
|
if (path === "/") {
|
|
20
20
|
return [PROTECTED_RESOURCE_METADATA_PATH];
|
|
21
21
|
}
|
|
22
|
-
return [`${PROTECTED_RESOURCE_METADATA_PATH}${path}`];
|
|
22
|
+
return [PROTECTED_RESOURCE_METADATA_PATH, `${PROTECTED_RESOURCE_METADATA_PATH}${path}`];
|
|
23
23
|
}
|
|
24
24
|
function formatHostnameForUrl(hostname) {
|
|
25
25
|
if (hostname.includes(":") && !hostname.startsWith("[")) {
|
|
@@ -157,6 +157,9 @@ export function createHttpServer(options) {
|
|
|
157
157
|
const nodeServer = http.createServer(async (req, res) => {
|
|
158
158
|
const requestUrl = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
159
159
|
try {
|
|
160
|
+
if (options.requestHandler !== undefined && (await options.requestHandler(req, res))) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
160
163
|
if (protectedResourceMetadataBody !== undefined &&
|
|
161
164
|
req.method === "GET" &&
|
|
162
165
|
getProtectedResourceMetadataPaths(path).includes(requestUrl.pathname)) {
|
|
@@ -249,6 +252,9 @@ export function createHttpServer(options) {
|
|
|
249
252
|
};
|
|
250
253
|
};
|
|
251
254
|
httpServer.handleRequest = async (req, res) => {
|
|
255
|
+
if (options.requestHandler !== undefined && (await options.requestHandler(req, res))) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
252
258
|
const { baseUrl } = req;
|
|
253
259
|
const protectedResourcePath = typeof baseUrl === "string" && baseUrl.length > 0 ? baseUrl : "/mcp";
|
|
254
260
|
if (!(await authorizeHttpRequest(req, res, protectedResourcePath))) {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { Server, TypedSchema, ImageContent, AudioContent, EmbeddedResource,
|
|
|
3
3
|
export { createExpressMiddleware, createExpressOAuthHandlers, createProtectedResourceMetadataRouter } from "./express-middleware.js";
|
|
4
4
|
export type { CreateExpressOAuthHandlersOptions } from "./express-middleware.js";
|
|
5
5
|
export { createHttpServer, createProtectedResourceMetadataDocument } from "./http-server.js";
|
|
6
|
-
export type { HttpToolContext, HttpToolHandler, HttpListenOptions, HttpServer, HttpServerHandle, HttpTransportOptions, ProtectedResourceMetadataOptions, TinyHttpMcpServerOAuthOptions } from "./http-server.js";
|
|
6
|
+
export type { HttpToolContext, HttpToolHandler, HttpAdditionalRequestHandler, HttpListenOptions, HttpServer, HttpServerHandle, HttpTransportOptions, ProtectedResourceMetadataOptions, TinyHttpMcpServerOAuthOptions } from "./http-server.js";
|
|
7
7
|
export { TokenVerificationError } from "./auth.js";
|
|
8
8
|
export type { RequestAuthInfo, TokenVerifier, VerifiedAccessToken } from "./auth.js";
|
|
9
9
|
export { StreamableHttpTransport } from "./http-transport.js";
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createHttpServer, createProtectedResourceMetadataDocument } from "./http-server.js";
|
|
2
|
-
export type { HttpToolContext, HttpToolHandler, HttpListenOptions, HttpServer, HttpServerHandle, HttpTransportOptions, ProtectedResourceMetadataOptions, TinyHttpMcpServerOAuthOptions } from "./http-server.js";
|
|
2
|
+
export type { HttpToolContext, HttpToolHandler, HttpAdditionalRequestHandler, HttpListenOptions, HttpServer, HttpServerHandle, HttpTransportOptions, ProtectedResourceMetadataOptions, TinyHttpMcpServerOAuthOptions } from "./http-server.js";
|
|
3
3
|
export { TokenVerificationError } from "./auth.js";
|
|
4
4
|
export type { RequestAuthInfo, TokenVerifier, VerifiedAccessToken } from "./auth.js";
|
|
5
5
|
export { StreamableHttpTransport } from "./http-transport.js";
|