@dexto/server 1.13.4 → 1.14.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/hono/index.cjs +3 -2
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +7 -3
- package/dist/hono/middleware/auth.cjs +42 -32
- package/dist/hono/middleware/auth.d.ts +15 -1
- package/dist/hono/middleware/auth.d.ts.map +1 -1
- package/dist/hono/middleware/auth.js +39 -31
- package/dist/hono/node/index.cjs +33 -22
- package/dist/hono/node/index.d.ts +1 -0
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +33 -22
- package/dist/hono/routes/agents.d.ts +14 -14
- package/dist/hono/routes/greeting.d.ts +13 -13
- package/dist/hono/routes/key.d.ts +4 -4
- package/dist/hono/routes/llm.d.ts +54 -54
- package/dist/hono/routes/memory.d.ts +10 -10
- package/dist/hono/routes/messages.d.ts +8 -8
- package/dist/hono/routes/models.d.ts +6 -6
- package/dist/hono/routes/openrouter.d.ts +6 -6
- package/dist/hono/routes/prompts.d.ts +2 -2
- package/dist/hono/routes/queue.d.ts +16 -16
- package/dist/hono/routes/resources.d.ts +2 -2
- package/dist/hono/routes/schedules.d.ts +12 -12
- package/dist/hono/routes/search.d.ts +4 -4
- package/dist/hono/routes/sessions.d.ts +24 -24
- package/dist/hono/routes/system-prompt.d.ts +2 -2
- package/dist/hono/routes/webhooks.d.ts +2 -2
- package/dist/hono/routes/workspaces.d.ts +2 -2
- package/dist/hono/types.d.ts +2 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/mcp/mcp-handler.cjs +32 -32
- package/dist/mcp/mcp-handler.d.ts +9 -3
- package/dist/mcp/mcp-handler.d.ts.map +1 -1
- package/dist/mcp/mcp-handler.js +32 -32
- package/package.json +15 -10
package/dist/mcp/mcp-handler.js
CHANGED
|
@@ -20,7 +20,7 @@ async function createMcpTransport(transportType = "http") {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
async function initializeMcpServer(agent, agentCardData, mcpTransport) {
|
|
23
|
+
async function initializeMcpServer(agent, agentCardData, mcpTransport, context = { getAgent: () => agent, getAgentCard: () => agentCardData }) {
|
|
24
24
|
const mcpServer = new McpServer(
|
|
25
25
|
{ name: agentCardData.name, version: agentCardData.version },
|
|
26
26
|
{
|
|
@@ -31,36 +31,33 @@ async function initializeMcpServer(agent, agentCardData, mcpTransport) {
|
|
|
31
31
|
);
|
|
32
32
|
const toolName = "chat_with_agent";
|
|
33
33
|
const toolDescription = "Allows you to chat with the an AI agent. Send a message to interact.";
|
|
34
|
-
mcpServer.
|
|
34
|
+
mcpServer.registerTool(
|
|
35
35
|
toolName,
|
|
36
|
-
toolDescription,
|
|
37
|
-
{ message: z.string() },
|
|
36
|
+
{ description: toolDescription, inputSchema: { message: z.string() } },
|
|
38
37
|
async ({ message }) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
const session = await agent.createSession(`mcp-${randomUUID()}`);
|
|
38
|
+
const agent2 = context.getAgent();
|
|
39
|
+
agent2.logger.info(`MCP tool '${toolName}' call started`);
|
|
40
|
+
const session = await agent2.createSession(`mcp-${randomUUID()}`);
|
|
43
41
|
try {
|
|
44
|
-
const text = await
|
|
45
|
-
|
|
46
|
-
`MCP tool '${toolName}' sending response: ${text?.substring(0, 100)}${(text?.length ?? 0) > 100 ? "..." : ""}`
|
|
47
|
-
);
|
|
42
|
+
const text = await agent2.run(message, void 0, void 0, session.id);
|
|
43
|
+
agent2.logger.info(`MCP tool '${toolName}' call completed`);
|
|
48
44
|
return { content: [{ type: "text", text: text ?? "" }] };
|
|
49
45
|
} finally {
|
|
50
|
-
await
|
|
51
|
-
(err) => agent.logger.warn(`Failed to cleanup MCP session ${session.id}: ${err}`)
|
|
52
|
-
);
|
|
46
|
+
await agent2.deleteSession(session.id).catch(() => agent2.logger.warn(`Failed to cleanup MCP session ${session.id}`));
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
49
|
);
|
|
56
50
|
agent.logger.info(`Registered MCP tool: '${toolName}'`);
|
|
57
|
-
await
|
|
51
|
+
await registerAgentCardResource(mcpServer, () => context.getAgentCard(), agent.logger);
|
|
58
52
|
agent.logger.info(`Initializing MCP protocol server connection...`);
|
|
59
53
|
await mcpServer.connect(mcpTransport);
|
|
60
54
|
agent.logger.info(`\u2705 MCP server protocol connected via transport.`);
|
|
61
55
|
return mcpServer;
|
|
62
56
|
}
|
|
63
|
-
|
|
57
|
+
function initializeAgentCardResource(mcpServer, agentCardData, agentLogger) {
|
|
58
|
+
return registerAgentCardResource(mcpServer, () => agentCardData, agentLogger);
|
|
59
|
+
}
|
|
60
|
+
async function registerAgentCardResource(mcpServer, getAgentCard, agentLogger) {
|
|
64
61
|
const agentCardResourceProgrammaticName = "agentCard";
|
|
65
62
|
const agentCardResourceUri = "dexto://agent/card";
|
|
66
63
|
try {
|
|
@@ -71,12 +68,17 @@ async function initializeAgentCardResource(mcpServer, agentCardData, agentLogger
|
|
|
71
68
|
{
|
|
72
69
|
uri: uri.href,
|
|
73
70
|
type: "application/json",
|
|
74
|
-
text: JSON.stringify(
|
|
71
|
+
text: JSON.stringify(getAgentCard(), null, 2)
|
|
75
72
|
}
|
|
76
73
|
]
|
|
77
74
|
};
|
|
78
75
|
};
|
|
79
|
-
mcpServer.
|
|
76
|
+
mcpServer.registerResource(
|
|
77
|
+
agentCardResourceProgrammaticName,
|
|
78
|
+
agentCardResourceUri,
|
|
79
|
+
{},
|
|
80
|
+
readCallback
|
|
81
|
+
);
|
|
80
82
|
agentLogger.info(
|
|
81
83
|
`Registered MCP Resource: '${agentCardResourceProgrammaticName}' at URI '${agentCardResourceUri}'`
|
|
82
84
|
);
|
|
@@ -91,23 +93,21 @@ function createMcpHttpHandlers(mcpTransport) {
|
|
|
91
93
|
logger.info("Non-HTTP transport detected. Skipping HTTP route setup.");
|
|
92
94
|
return null;
|
|
93
95
|
}
|
|
94
|
-
const
|
|
95
|
-
logger.info(`MCP
|
|
96
|
+
const handleRequest = async (req, res, body) => {
|
|
97
|
+
logger.info(`MCP ${req.method} request received`);
|
|
96
98
|
try {
|
|
97
99
|
await mcpTransport.handleRequest(req, res, body);
|
|
98
|
-
} catch
|
|
99
|
-
logger.error(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
} catch (err) {
|
|
107
|
-
logger.error(`MCP GET error: ${JSON.stringify(err, null, 2)}`);
|
|
100
|
+
} catch {
|
|
101
|
+
logger.error("MCP HTTP request failed");
|
|
102
|
+
if (!res.headersSent) {
|
|
103
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
104
|
+
res.end(JSON.stringify({ error: "Internal Server Error" }));
|
|
105
|
+
} else if (!res.writableEnded) {
|
|
106
|
+
res.destroy();
|
|
107
|
+
}
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
return { handlePost, handleGet };
|
|
110
|
+
return { handlePost: handleRequest, handleGet: handleRequest, handleDelete: handleRequest };
|
|
111
111
|
}
|
|
112
112
|
export {
|
|
113
113
|
createMcpHttpHandlers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
"import": "./dist/hono/node/index.js",
|
|
23
23
|
"require": "./dist/hono/node/index.cjs"
|
|
24
24
|
},
|
|
25
|
-
"./package.json": "./package.json"
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
"./hono/auth": {
|
|
27
|
+
"types": "./dist/hono/middleware/auth.d.ts",
|
|
28
|
+
"import": "./dist/hono/middleware/auth.js",
|
|
29
|
+
"require": "./dist/hono/middleware/auth.cjs"
|
|
30
|
+
}
|
|
26
31
|
},
|
|
27
32
|
"dependencies": {
|
|
28
33
|
"@hono/node-server": "1.19.13",
|
|
@@ -30,14 +35,14 @@
|
|
|
30
35
|
"hono": "^4.12.12",
|
|
31
36
|
"ws": "^8.18.1",
|
|
32
37
|
"yaml": "^2.8.3",
|
|
33
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
34
|
-
"@dexto/agent-config": "1.
|
|
35
|
-
"@dexto/agent-management": "1.
|
|
36
|
-
"@dexto/core": "1.
|
|
37
|
-
"@dexto/image-local": "1.
|
|
38
|
-
"@dexto/llm": "1.
|
|
39
|
-
"@dexto/storage": "1.
|
|
40
|
-
"@dexto/tools-scheduler": "1.
|
|
38
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
39
|
+
"@dexto/agent-config": "1.14.0",
|
|
40
|
+
"@dexto/agent-management": "1.14.0",
|
|
41
|
+
"@dexto/core": "1.14.0",
|
|
42
|
+
"@dexto/image-local": "1.14.0",
|
|
43
|
+
"@dexto/llm": "1.14.0",
|
|
44
|
+
"@dexto/storage": "1.14.0",
|
|
45
|
+
"@dexto/tools-scheduler": "1.14.0"
|
|
41
46
|
},
|
|
42
47
|
"files": [
|
|
43
48
|
"dist",
|