added auth to remote mcps

This commit is contained in:
Luxferre
2026-03-21 16:29:28 +02:00
parent d24150d2e9
commit c2bc527b30
3 changed files with 107 additions and 46 deletions
+54 -30
View File
@@ -54,8 +54,6 @@ This file defines your models, MCP servers, and agent profiles.
tool_response_threshold = 10000 # Bytes after which tool results are buffered to files
[models.default]
```
model_id = "env:DEFAULT_MODEL_ID"
endpoint = "env:DEFAULT_MODEL_ENDPOINT"
api_key = "env:DEFAULT_MODEL_API_KEY"
@@ -67,6 +65,12 @@ transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
[mcp_servers.remote_tools]
transport = "sse"
url = "https://api.example.com/mcp"
auth_token = "env:MCP_API_KEY" # Optional Bearer token
headers = { "X-Custom-Header" = "value" } # Optional custom headers
[agents.coordinator]
role = "COORDINATOR"
model_id = "default"
@@ -105,6 +109,26 @@ user's request and delegate tasks accordingly.
./bin/sidekick-tui
```
### Running the Sidekick MCP Server
Sidekick can also act as an MCP server, allowing other LLM-powered applications to leverage its agentic capabilities.
1. Configure the `mcp_listener` in `config.toml`:
```toml
[mcp_listener]
transport = "sse" # "stdio" or "sse"/"http"
port = 8080 # for sse/http
```
2. Run the MCP server:
```bash
./bin/sidekick-mcp
```
The server provides a `query` tool that routes requests to your coordinator agent, maintaining conversation history if provided.
* **Input:** Type your messages at the bottom prompt.
* **Send:** Press `Enter` to send a message.
* **Quit:** Press `ctrl+c` to exit.
@@ -116,43 +140,43 @@ user's request and delegate tasks accordingly.
package main
import (
"context"
"fmt"
"log"
"context"
"fmt"
"log"
"github.com/yourusername/sidekick-ng"
"github.com/yourusername/sidekick-ng"
)
func main() {
// 1. Load Configuration
cfg, err := sidekick.LoadConfig("config.toml")
if err != nil {
log.Fatal(err)
}
// 1. Load Configuration
cfg, err := sidekick.LoadConfig("config.toml")
if err != nil {
log.Fatal(err)
}
// 2. Load and Apply Prompts (Optional)
tmpl, _ := sidekick.LoadPrompts("prompts.toml")
// 2. Load and Apply Prompts (Optional)
tmpl, _ := sidekick.LoadPrompts("prompts.toml")
// 3. Initialize Agent
agentCfg := cfg.Agents["coordinator"]
// Apply template override if exists
if tmpl != nil && tmpl.Lookup("coordinator") != nil {
if rendered, err := sidekick.RenderPrompt(tmpl, "coordinator"); err == nil {
agentCfg.SystemPrompt = rendered
}
}
// 3. Initialize Agent
agentCfg := cfg.Agents["coordinator"]
// Apply template override if exists
if tmpl != nil && tmpl.Lookup("coordinator") != nil {
if rendered, err := sidekick.RenderPrompt(tmpl, "coordinator"); err == nil {
agentCfg.SystemPrompt = rendered
}
}
agent := sidekick.NewAgent("coordinator", agentCfg, cfg)
agent := sidekick.NewAgent("coordinator", agentCfg, cfg)
// 4. Run the Agent Loop
ctx := context.Background()
result, err := agent.Run(ctx, "What files are in the /tmp directory?")
if err != nil {
log.Fatal(err)
}
// 4. Run the Agent Loop
ctx := context.Background()
result, err := agent.Run(ctx, "What files are in the /tmp directory?")
if err != nil {
log.Fatal(err)
}
fmt.Println(result)
fmt.Println(result)
}
```