@prefecthq/fastmcp-ts 0.0.5 → 0.1.0
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/cli/entrypoint-runtime.cjs +87 -0
- package/dist/cli/entrypoint-runtime.cjs.map +1 -0
- package/dist/cli/index.cjs +85 -37
- package/dist/cli/index.cjs.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.js +18 -7
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -595,6 +595,7 @@ declare class FastMCP {
|
|
|
595
595
|
private _primaryState;
|
|
596
596
|
private _httpServer;
|
|
597
597
|
private _address;
|
|
598
|
+
private _isRunning;
|
|
598
599
|
private _sessions;
|
|
599
600
|
private _primaryServer;
|
|
600
601
|
private _toolRegisteredCallbacks;
|
|
@@ -770,6 +771,12 @@ declare class FastMCP {
|
|
|
770
771
|
getContext(): McpContext;
|
|
771
772
|
/** The bound address after run() resolves for the http transport. Null for stdio or before run(). */
|
|
772
773
|
get address(): ServerAddress | null;
|
|
774
|
+
/**
|
|
775
|
+
* Whether `run()` or `connect()` has been called on this instance. Used by the
|
|
776
|
+
* CLI's entrypoint loader to detect servers that already started themselves via
|
|
777
|
+
* top-level code, so it doesn't attempt to start them a second time.
|
|
778
|
+
*/
|
|
779
|
+
get isRunning(): boolean;
|
|
773
780
|
connect(transport: Transport): Promise<void>;
|
|
774
781
|
run(options?: RunOptions): Promise<void>;
|
|
775
782
|
private _runHttpOAuth;
|
package/dist/server.js
CHANGED
|
@@ -681,6 +681,7 @@ var FastMCP = class {
|
|
|
681
681
|
_primaryState = /* @__PURE__ */ new Map();
|
|
682
682
|
_httpServer = null;
|
|
683
683
|
_address = null;
|
|
684
|
+
_isRunning = false;
|
|
684
685
|
_sessions = /* @__PURE__ */ new Map();
|
|
685
686
|
// Primary server used by connect() and stdio
|
|
686
687
|
_primaryServer;
|
|
@@ -1588,11 +1589,21 @@ var FastMCP = class {
|
|
|
1588
1589
|
get address() {
|
|
1589
1590
|
return this._address;
|
|
1590
1591
|
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Whether `run()` or `connect()` has been called on this instance. Used by the
|
|
1594
|
+
* CLI's entrypoint loader to detect servers that already started themselves via
|
|
1595
|
+
* top-level code, so it doesn't attempt to start them a second time.
|
|
1596
|
+
*/
|
|
1597
|
+
get isRunning() {
|
|
1598
|
+
return this._isRunning;
|
|
1599
|
+
}
|
|
1591
1600
|
async connect(transport) {
|
|
1601
|
+
this._isRunning = true;
|
|
1592
1602
|
this._primaryServer = this._makeServer();
|
|
1593
1603
|
await this._primaryServer.connect(transport);
|
|
1594
1604
|
}
|
|
1595
1605
|
async run(options) {
|
|
1606
|
+
this._isRunning = true;
|
|
1596
1607
|
const rawTransport = process.env.MCP_TRANSPORT ?? options?.transport ?? "stdio";
|
|
1597
1608
|
if (rawTransport !== "stdio" && rawTransport !== "http") {
|
|
1598
1609
|
throw new Error(`Unknown transport: "${rawTransport}". Supported: stdio, http.`);
|
|
@@ -1602,7 +1613,7 @@ var FastMCP = class {
|
|
|
1602
1613
|
const host = options?.host ?? process.env.MCP_HOST ?? "0.0.0.0";
|
|
1603
1614
|
const path = options?.path ?? process.env.MCP_PATH ?? "/mcp";
|
|
1604
1615
|
if (transport === "stdio") {
|
|
1605
|
-
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio");
|
|
1616
|
+
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
1606
1617
|
await this.connect(new StdioServerTransport(options?.stdin, options?.stdout));
|
|
1607
1618
|
} else if (this._oauth) {
|
|
1608
1619
|
await this._runHttpOAuth(port, host, path);
|
|
@@ -1611,10 +1622,10 @@ var FastMCP = class {
|
|
|
1611
1622
|
}
|
|
1612
1623
|
}
|
|
1613
1624
|
async _runHttpOAuth(port, host, path) {
|
|
1614
|
-
const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp");
|
|
1625
|
+
const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
1615
1626
|
const express = (await import("express")).default;
|
|
1616
|
-
const { mcpAuthRouter } = await import("@modelcontextprotocol/sdk/server/auth/router");
|
|
1617
|
-
const { requireBearerAuth } = await import("@modelcontextprotocol/sdk/server/auth/middleware/bearerAuth");
|
|
1627
|
+
const { mcpAuthRouter } = await import("@modelcontextprotocol/sdk/server/auth/router.js");
|
|
1628
|
+
const { requireBearerAuth } = await import("@modelcontextprotocol/sdk/server/auth/middleware/bearerAuth.js");
|
|
1618
1629
|
const oauth = this._oauth;
|
|
1619
1630
|
const app = express();
|
|
1620
1631
|
const httpServer = await new Promise((resolve, reject) => {
|
|
@@ -1669,7 +1680,7 @@ var FastMCP = class {
|
|
|
1669
1680
|
this._address = { host: bound.address, port: bound.port, path };
|
|
1670
1681
|
}
|
|
1671
1682
|
async _runHttpSimple(port, host, path) {
|
|
1672
|
-
const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp");
|
|
1683
|
+
const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
1673
1684
|
const { createServer } = await import("http");
|
|
1674
1685
|
const auth = this._auth;
|
|
1675
1686
|
const corsHeaders = {
|
|
@@ -2294,7 +2305,7 @@ async function buildProxyFromClient(client, options) {
|
|
|
2294
2305
|
async function createProxy(config, name) {
|
|
2295
2306
|
let transport;
|
|
2296
2307
|
if (config.type === "stdio") {
|
|
2297
|
-
const { StdioClientTransport } = await import("@modelcontextprotocol/sdk/client/stdio");
|
|
2308
|
+
const { StdioClientTransport } = await import("@modelcontextprotocol/sdk/client/stdio.js");
|
|
2298
2309
|
transport = new StdioClientTransport({
|
|
2299
2310
|
command: config.command,
|
|
2300
2311
|
args: config.args,
|
|
@@ -2302,7 +2313,7 @@ async function createProxy(config, name) {
|
|
|
2302
2313
|
cwd: config.cwd
|
|
2303
2314
|
});
|
|
2304
2315
|
} else {
|
|
2305
|
-
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp");
|
|
2316
|
+
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
2306
2317
|
transport = new StreamableHTTPClientTransport(new URL(config.url), {
|
|
2307
2318
|
requestInit: config.requestInit
|
|
2308
2319
|
});
|