feat(mcp-server): support env var AGENT_TOOLS_ONLY (#145)
This commit is contained in:
@@ -8,10 +8,10 @@ Let LLM-functions tools/agents be used through the Model Context Protocol.
|
|||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"tools": {
|
"tools": {
|
||||||
"command": "node",
|
"command": "npx",
|
||||||
"args": [
|
"args": [
|
||||||
"<path-to-llm-functions>/mcp/server/index.js",
|
"mcp-llm-functions",
|
||||||
"<path-to-llm-functions>"
|
"<llm-functions-dir>"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,11 +26,15 @@ Let LLM-functions tools/agents be used through the Model Context Protocol.
|
|||||||
"<agent-name>": {
|
"<agent-name>": {
|
||||||
"command": "node",
|
"command": "node",
|
||||||
"args": [
|
"args": [
|
||||||
"<path-to-llm-functions>/mcp/server/index.js",
|
"mcp-llm-functions",
|
||||||
"<path-to-llm-functions>",
|
"<llm-functions-dir>"
|
||||||
"<agent-name>",
|
"<agent-name>",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
- `AGENT_TOOLS_ONLY`: Set to `true` or `1` to ignore shared tools and display only agent tools.
|
||||||
+12
-1
@@ -33,6 +33,18 @@ try {
|
|||||||
console.error(`Failed to read functions at '${functionsJsonPath}'`);
|
console.error(`Failed to read functions at '${functionsJsonPath}'`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
const agentToolsOnly = process.env["AGENT_TOOLS_ONLY"] === "true" || process.env["AGENT_TOOLS_ONLY"] === "1";
|
||||||
|
functions = functions.filter(f => {
|
||||||
|
if (f.mcp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (agentToolsOnly) {
|
||||||
|
return f.agent;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const env = Object.assign({}, process.env, {
|
const env = Object.assign({}, process.env, {
|
||||||
PATH: `${path.join(rootDir, "bin")}:${process.env.PATH}`
|
PATH: `${path.join(rootDir, "bin")}:${process.env.PATH}`
|
||||||
});
|
});
|
||||||
@@ -114,7 +126,6 @@ function runCommand(command, args, env) {
|
|||||||
async function runServer() {
|
async function runServer() {
|
||||||
const transport = new StdioServerTransport();
|
const transport = new StdioServerTransport();
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
console.error("LLM-Functions MCP Server running on stdio");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runServer().catch(console.error);
|
runServer().catch(console.error);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mcp-llm-functions",
|
"name": "mcp-llm-functions",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "Let LLM-functions tools/agents be used through the Model Context Protocol",
|
"description": "Let LLM-functions tools/agents be used through the Model Context Protocol",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "sigoden <sigoden@gmail.com>",
|
"author": "sigoden <sigoden@gmail.com>",
|
||||||
|
|||||||
Reference in New Issue
Block a user