@pencil-agent/nano-pencil 1.6.3 → 1.6.4
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.
|
@@ -11,6 +11,9 @@ export declare class MCPManager {
|
|
|
11
11
|
constructor();
|
|
12
12
|
/**
|
|
13
13
|
* Initialize MCP manager and load tools
|
|
14
|
+
*
|
|
15
|
+
* Note: This only adds server configurations and creates tool definitions.
|
|
16
|
+
* Servers will be started lazily when tools are first called.
|
|
14
17
|
*/
|
|
15
18
|
initialize(): Promise<void>;
|
|
16
19
|
/**
|
package/dist/core/mcp-manager.js
CHANGED
|
@@ -4,8 +4,27 @@
|
|
|
4
4
|
* Manages MCP client lifecycle and tool integration.
|
|
5
5
|
*/
|
|
6
6
|
import { MCPClient } from "./mcp/mcp-client.js";
|
|
7
|
-
import {
|
|
7
|
+
import { createMCPTool } from "./mcp/mcp-adapter.js";
|
|
8
8
|
import { listEnabledMCPServers } from "./mcp/mcp-config.js";
|
|
9
|
+
// Pre-defined MCP tool schemas for servers that don't need to be started upfront
|
|
10
|
+
// These will be available to the AI, and the server will be started on first use
|
|
11
|
+
const PREDEFINED_MCP_TOOLS = {
|
|
12
|
+
filesystem: [
|
|
13
|
+
{ name: "filesystem/read", description: "Read a file from the filesystem" },
|
|
14
|
+
{ name: "filesystem/write", description: "Write content to a file" },
|
|
15
|
+
{ name: "filesystem/list", description: "List directory contents" },
|
|
16
|
+
],
|
|
17
|
+
fetch: [{ name: "fetch/fetch", description: "Fetch a web page" }],
|
|
18
|
+
puppeteer: [
|
|
19
|
+
{ name: "puppeteer/navigate", description: "Navigate to a URL" },
|
|
20
|
+
{ name: "puppeteer/screenshot", description: "Take a screenshot" },
|
|
21
|
+
],
|
|
22
|
+
sqlite: [{ name: "sqlite/query", description: "Query SQLite database" }],
|
|
23
|
+
git: [
|
|
24
|
+
{ name: "git/clone", description: "Clone a git repository" },
|
|
25
|
+
{ name: "git/status", description: "Get git status" },
|
|
26
|
+
],
|
|
27
|
+
};
|
|
9
28
|
export class MCPManager {
|
|
10
29
|
client;
|
|
11
30
|
tools = [];
|
|
@@ -14,19 +33,36 @@ export class MCPManager {
|
|
|
14
33
|
}
|
|
15
34
|
/**
|
|
16
35
|
* Initialize MCP manager and load tools
|
|
36
|
+
*
|
|
37
|
+
* Note: This only adds server configurations and creates tool definitions.
|
|
38
|
+
* Servers will be started lazily when tools are first called.
|
|
17
39
|
*/
|
|
18
40
|
async initialize() {
|
|
19
41
|
// Load enabled servers
|
|
20
42
|
const enabledServers = listEnabledMCPServers();
|
|
21
43
|
for (const serverConfig of enabledServers) {
|
|
22
44
|
this.client.addServer(serverConfig);
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
// Don't start servers here - they will be started lazily on first use
|
|
46
|
+
// Starting servers here would block agent session creation
|
|
47
|
+
}
|
|
48
|
+
// Create tool definitions from predefined schemas
|
|
49
|
+
// This avoids starting servers just to list their tools
|
|
50
|
+
for (const server of enabledServers) {
|
|
51
|
+
const predefinedTools = PREDEFINED_MCP_TOOLS[server.id];
|
|
52
|
+
if (predefinedTools) {
|
|
53
|
+
for (const toolDef of predefinedTools) {
|
|
54
|
+
this.tools.push(createMCPTool(this.client, {
|
|
55
|
+
name: toolDef.name,
|
|
56
|
+
description: toolDef.description,
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {},
|
|
60
|
+
},
|
|
61
|
+
serverId: server.id,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
26
64
|
}
|
|
27
65
|
}
|
|
28
|
-
// Load tools from all servers
|
|
29
|
-
this.tools = await loadMCPTools(this.client);
|
|
30
66
|
}
|
|
31
67
|
/**
|
|
32
68
|
* Get all MCP tools as NanoPencil ToolDefinitions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pencil-agent/nano-pencil",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "CLI writing agent with read, bash, edit, write tools and session management. Based on pi; supports DashScope Coding Plan. Soul enabled by default for AI personality evolution.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|