Skip to content

Commit

Permalink
feat(mcp-server): support env var AGENT_TOOLS_ONLY (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Dec 12, 2024
1 parent 3584b5c commit e8ffb41
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
14 changes: 9 additions & 5 deletions mcp/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Let LLM-functions tools/agents be used through the Model Context Protocol.
{
"mcpServers": {
"tools": {
"command": "node",
"command": "npx",
"args": [
"<path-to-llm-functions>/mcp/server/index.js",
"<path-to-llm-functions>"
"mcp-llm-functions",
"<llm-functions-dir>"
]
}
}
Expand All @@ -26,11 +26,15 @@ Let LLM-functions tools/agents be used through the Model Context Protocol.
"<agent-name>": {
"command": "node",
"args": [
"<path-to-llm-functions>/mcp/server/index.js",
"<path-to-llm-functions>",
"mcp-llm-functions",
"<llm-functions-dir>"
"<agent-name>",
]
}
}
}
```

## Environment Variables

- `AGENT_TOOLS_ONLY`: Set to `true` or `1` to ignore shared tools and display only agent tools.
13 changes: 12 additions & 1 deletion mcp/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ try {
console.error(`Failed to read functions at '${functionsJsonPath}'`);
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, {
PATH: `${path.join(rootDir, "bin")}:${process.env.PATH}`
});
Expand Down Expand Up @@ -114,7 +126,6 @@ function runCommand(command, args, env) {
async function runServer() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("LLM-Functions MCP Server running on stdio");
}

runServer().catch(console.error);
2 changes: 1 addition & 1 deletion mcp/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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",
"license": "MIT",
"author": "sigoden <[email protected]>",
Expand Down

0 comments on commit e8ffb41

Please sign in to comment.