@hailer/mcp 0.0.1
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/.claude/commands/tool-builder.md +37 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/settings.json +8 -0
- package/.claude/settings.local.json +49 -0
- package/.claude/skills/activity-api/SKILL.md +96 -0
- package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
- package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
- package/.claude/skills/agent-building/SKILL.md +243 -0
- package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
- package/.claude/skills/agent-building/references/code-examples.md +587 -0
- package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
- package/.claude/skills/app-api/SKILL.md +219 -0
- package/.claude/skills/app-api/references/app-endpoints.md +759 -0
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
- package/.claude/skills/create-app-skill/SKILL.md +1101 -0
- package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
- package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
- package/.claude/skills/hailer-api/SKILL.md +283 -0
- package/.claude/skills/hailer-api/references/activities.md +620 -0
- package/.claude/skills/hailer-api/references/authentication.md +216 -0
- package/.claude/skills/hailer-api/references/datasets.md +437 -0
- package/.claude/skills/hailer-api/references/files.md +301 -0
- package/.claude/skills/hailer-api/references/insights.md +469 -0
- package/.claude/skills/hailer-api/references/workflows.md +720 -0
- package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
- package/.claude/skills/insight-api/SKILL.md +185 -0
- package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
- package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
- package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
- package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
- package/.claude/skills/local-first-skill/SKILL.md +570 -0
- package/.claude/skills/mcp-tools/SKILL.md +419 -0
- package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
- package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
- package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
- package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
- package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
- package/.claude/skills/remove-app-skill/SKILL.md +985 -0
- package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
- package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
- package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
- package/.claude/skills/skill-testing/README.md +137 -0
- package/.claude/skills/skill-testing/SKILL.md +348 -0
- package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
- package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
- package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
- package/.claude/skills/tool-builder/SKILL.md +328 -0
- package/.claude/skills/update-app-skill/SKILL.md +970 -0
- package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
- package/.env.example +81 -0
- package/.mcp.json +13 -0
- package/README.md +297 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +74 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +5 -0
- package/dist/client/adaptive-documentation-bot.d.ts +108 -0
- package/dist/client/adaptive-documentation-bot.js +475 -0
- package/dist/client/adaptive-documentation-types.d.ts +66 -0
- package/dist/client/adaptive-documentation-types.js +9 -0
- package/dist/client/agent-activity-bot.d.ts +51 -0
- package/dist/client/agent-activity-bot.js +166 -0
- package/dist/client/agent-tracker.d.ts +499 -0
- package/dist/client/agent-tracker.js +659 -0
- package/dist/client/description-updater.d.ts +56 -0
- package/dist/client/description-updater.js +259 -0
- package/dist/client/log-parser.d.ts +72 -0
- package/dist/client/log-parser.js +387 -0
- package/dist/client/mcp-client.d.ts +50 -0
- package/dist/client/mcp-client.js +532 -0
- package/dist/client/message-processor.d.ts +35 -0
- package/dist/client/message-processor.js +352 -0
- package/dist/client/multi-bot-manager.d.ts +24 -0
- package/dist/client/multi-bot-manager.js +74 -0
- package/dist/client/providers/anthropic-provider.d.ts +19 -0
- package/dist/client/providers/anthropic-provider.js +631 -0
- package/dist/client/providers/llm-provider.d.ts +47 -0
- package/dist/client/providers/llm-provider.js +367 -0
- package/dist/client/providers/openai-provider.d.ts +23 -0
- package/dist/client/providers/openai-provider.js +621 -0
- package/dist/client/simple-llm-caller.d.ts +19 -0
- package/dist/client/simple-llm-caller.js +100 -0
- package/dist/client/skill-generator.d.ts +81 -0
- package/dist/client/skill-generator.js +386 -0
- package/dist/client/test-adaptive-bot.d.ts +9 -0
- package/dist/client/test-adaptive-bot.js +82 -0
- package/dist/client/token-pricing.d.ts +38 -0
- package/dist/client/token-pricing.js +127 -0
- package/dist/client/token-tracker.d.ts +232 -0
- package/dist/client/token-tracker.js +457 -0
- package/dist/client/token-usage-bot.d.ts +53 -0
- package/dist/client/token-usage-bot.js +153 -0
- package/dist/client/tool-executor.d.ts +69 -0
- package/dist/client/tool-executor.js +159 -0
- package/dist/client/tool-schema-loader.d.ts +60 -0
- package/dist/client/tool-schema-loader.js +178 -0
- package/dist/client/types.d.ts +69 -0
- package/dist/client/types.js +7 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.js +296 -0
- package/dist/core.d.ts +26 -0
- package/dist/core.js +147 -0
- package/dist/lib/context-manager.d.ts +111 -0
- package/dist/lib/context-manager.js +431 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +277 -0
- package/dist/lib/materialize.d.ts +3 -0
- package/dist/lib/materialize.js +101 -0
- package/dist/lib/normalizedName.d.ts +7 -0
- package/dist/lib/normalizedName.js +48 -0
- package/dist/lib/prompt-length-manager.d.ts +81 -0
- package/dist/lib/prompt-length-manager.js +457 -0
- package/dist/lib/terminal-prompt.d.ts +9 -0
- package/dist/lib/terminal-prompt.js +108 -0
- package/dist/mcp/UserContextCache.d.ts +56 -0
- package/dist/mcp/UserContextCache.js +163 -0
- package/dist/mcp/auth.d.ts +2 -0
- package/dist/mcp/auth.js +29 -0
- package/dist/mcp/hailer-clients.d.ts +42 -0
- package/dist/mcp/hailer-clients.js +246 -0
- package/dist/mcp/signal-handler.d.ts +45 -0
- package/dist/mcp/signal-handler.js +317 -0
- package/dist/mcp/tool-registry.d.ts +100 -0
- package/dist/mcp/tool-registry.js +306 -0
- package/dist/mcp/tools/activity.d.ts +15 -0
- package/dist/mcp/tools/activity.js +955 -0
- package/dist/mcp/tools/app.d.ts +20 -0
- package/dist/mcp/tools/app.js +1488 -0
- package/dist/mcp/tools/discussion.d.ts +19 -0
- package/dist/mcp/tools/discussion.js +950 -0
- package/dist/mcp/tools/file.d.ts +15 -0
- package/dist/mcp/tools/file.js +119 -0
- package/dist/mcp/tools/insight.d.ts +17 -0
- package/dist/mcp/tools/insight.js +806 -0
- package/dist/mcp/tools/skill.d.ts +10 -0
- package/dist/mcp/tools/skill.js +279 -0
- package/dist/mcp/tools/user.d.ts +10 -0
- package/dist/mcp/tools/user.js +108 -0
- package/dist/mcp/tools/workflow-template.d.ts +19 -0
- package/dist/mcp/tools/workflow-template.js +822 -0
- package/dist/mcp/tools/workflow.d.ts +18 -0
- package/dist/mcp/tools/workflow.js +1362 -0
- package/dist/mcp/utils/api-errors.d.ts +45 -0
- package/dist/mcp/utils/api-errors.js +160 -0
- package/dist/mcp/utils/data-transformers.d.ts +102 -0
- package/dist/mcp/utils/data-transformers.js +194 -0
- package/dist/mcp/utils/file-upload.d.ts +33 -0
- package/dist/mcp/utils/file-upload.js +148 -0
- package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
- package/dist/mcp/utils/hailer-api-client.js +323 -0
- package/dist/mcp/utils/index.d.ts +13 -0
- package/dist/mcp/utils/index.js +39 -0
- package/dist/mcp/utils/logger.d.ts +42 -0
- package/dist/mcp/utils/logger.js +103 -0
- package/dist/mcp/utils/types.d.ts +286 -0
- package/dist/mcp/utils/types.js +7 -0
- package/dist/mcp/workspace-cache.d.ts +42 -0
- package/dist/mcp/workspace-cache.js +97 -0
- package/dist/mcp-server.d.ts +42 -0
- package/dist/mcp-server.js +280 -0
- package/package.json +56 -0
- package/tsconfig.json +23 -0
package/.env.example
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Hailer MCP Server Configuration
|
|
2
|
+
# Copy this file to .env.local and update with your own credentials
|
|
3
|
+
|
|
4
|
+
# ==============================================
|
|
5
|
+
# MCP SERVER CONFIGURATION (for external clients)
|
|
6
|
+
# ==============================================
|
|
7
|
+
|
|
8
|
+
# Hailer instance configuration
|
|
9
|
+
# Multiple agents can be configured with different API keys
|
|
10
|
+
# DO NOT USE YOUR LOGIN ALWAYS CREATE A +ai example WHEN INVITING THE MCP TO A WORKSPACE!
|
|
11
|
+
|
|
12
|
+
# ⚠️ CLIENT_CONFIGS is COMMENTED OUT by default
|
|
13
|
+
#
|
|
14
|
+
# MANUAL SETUP (if you want to configure now):
|
|
15
|
+
# 1. Create a Hailer user account with +ai suffix (e.g., yourname+ai@example.com)
|
|
16
|
+
# 2. Generate a unique API key for the mcpServerApiKey field (any random string)
|
|
17
|
+
# 3. Uncomment the CLIENT_CONFIGS below and fill in your credentials
|
|
18
|
+
# 4. Copy this file to .env.local (which is gitignored)
|
|
19
|
+
# 5. Never commit .env.local to version control
|
|
20
|
+
#
|
|
21
|
+
# EXAMPLE CONFIGURATION (uncomment and modify):
|
|
22
|
+
# CLIENT_CONFIGS='[
|
|
23
|
+
# {
|
|
24
|
+
# "email": "your-email+ai@example.com",
|
|
25
|
+
# "password": "your-password",
|
|
26
|
+
# "mcpServerApiKey": "unique-api-key-for-this-agent",
|
|
27
|
+
# "apiBaseUrl": "https://api.hailer.com"
|
|
28
|
+
# }
|
|
29
|
+
#]'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Workspace configuration path (optional)
|
|
34
|
+
# Point to a directory containing workspace configs (workflows.json, insights.json, etc.)
|
|
35
|
+
# Used by /ws-pull command to download workspace configuration
|
|
36
|
+
# If not set, looks in current directory
|
|
37
|
+
# WORKSPACE_CONFIG_PATH=/path/to/workspace-config
|
|
38
|
+
|
|
39
|
+
# Development apps path (optional)
|
|
40
|
+
# Point to a directory where Hailer apps will be scaffolded
|
|
41
|
+
# Keeps the repo clean from development app projects
|
|
42
|
+
# If not set, apps are created in current directory
|
|
43
|
+
# DEV_APPS_PATH=/path/to/hailer-apps
|
|
44
|
+
|
|
45
|
+
# Enable destructive operations (remove_workflow, remove_app, remove_insight, delete_template)
|
|
46
|
+
# ⚠️ SECURITY: NUCLEAR tools are HIDDEN and BLOCKED by default for safety
|
|
47
|
+
# When disabled (default): Nuclear tools don't appear in tool listings
|
|
48
|
+
# When enabled: Nuclear tools become available and visible
|
|
49
|
+
# Set to 'true' to explicitly enable destructive operations
|
|
50
|
+
# Default: false (nuclear tools completely hidden)
|
|
51
|
+
# ENABLE_NUCLEAR_TOOLS=true
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# ==============================================
|
|
55
|
+
# OPTIONAL: MCP CLIENT CONFIGURATION (automated agent)
|
|
56
|
+
# ==============================================
|
|
57
|
+
|
|
58
|
+
# Enable the MCP Client (enabled by default)
|
|
59
|
+
MCP_CLIENT_ENABLED=false
|
|
60
|
+
|
|
61
|
+
# LLM Provider API Keys (add at least one)
|
|
62
|
+
# ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
63
|
+
# OPENAI_API_KEY=sk-your-openai-key-here
|
|
64
|
+
|
|
65
|
+
# MCP Server URL (for client to call our own tools)
|
|
66
|
+
MCP_SERVER_URL=http://localhost:3030/api/mcp
|
|
67
|
+
#MCP_CLIENT_API_KEY=your-api-key
|
|
68
|
+
|
|
69
|
+
# MCP Agent User IDs (required for agent tagging - get these from Hailer)
|
|
70
|
+
MCP_CLIENT_AGENT_IDS='[]'
|
|
71
|
+
|
|
72
|
+
# Bot Features (optional, defaults to true)
|
|
73
|
+
TOKEN_USAGE_BOT_ENABLED=false
|
|
74
|
+
AGENT_ACTIVITY_BOT_ENABLED=false
|
|
75
|
+
|
|
76
|
+
# Adaptive Documentation Bot (automatically improves tool descriptions based on errors)
|
|
77
|
+
ADAPTIVE_DOCUMENTATION_BOT_ENABLED=false
|
|
78
|
+
ADAPTIVE_AUTO_UPDATE=false
|
|
79
|
+
ADAPTIVE_UPDATE_INTERVAL=60000
|
|
80
|
+
ADAPTIVE_MIN_ERROR_COUNT=3
|
|
81
|
+
ADAPTIVE_SKILL_GENERATION=false
|
package/.mcp.json
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Hailer MCP
|
|
2
|
+
|
|
3
|
+
**MCP** stands for **Model Context Protocol** - a standardized way for AI assistants to securely access and interact with external tools and data sources. This project implements both an MCP Server (providing Hailer tools to external MCP clients) and an MCP Client (automated agents that respond to mentions in Hailer chats).
|
|
4
|
+
|
|
5
|
+
## ToDo List
|
|
6
|
+
- [ ] For questions during André's vacation, ask Tatu (Tatu Vähä-Tuisku) & Levi
|
|
7
|
+
|
|
8
|
+
MCP Client
|
|
9
|
+
- [ ] Allow agent to see/switch between workspaces
|
|
10
|
+
- [ ] let agent fill descriptions for workflows, and phases (empty, and add to existing)
|
|
11
|
+
- [ ] Let Bot read through old messages (didnt check 2024 week 26 messages, but 2025)
|
|
12
|
+
- [ ] Review HR AI Workspace, what fields are needed for prompt/behavior, and what notes to take
|
|
13
|
+
- [ ] Add Hailer data structure to system prompt
|
|
14
|
+
- [ ] Add system prompt and memory, fetch from HR for AI agents
|
|
15
|
+
- [ ] Hailer Bug: Sometimes agents response doesnt show (Hailer Bug suspected, because after page reload they are visible). maybe temporarily solve by addind 300ms delay for message, or send another signal to refresh/update
|
|
16
|
+
- [ ] Check which workflows and datasets Agent #1 and #2 have access to, Check CACHING
|
|
17
|
+
- [ ] reduce temperature to 0 for predictability
|
|
18
|
+
|
|
19
|
+
- [X] Provide additional context (which workspace, 10 most recent messages) when bot gets triggered
|
|
20
|
+
- [X] If 2 agents get asked in one message, make sure both respond
|
|
21
|
+
- [X] Read User ID from Hailer, to simplify the config
|
|
22
|
+
- [X] Test if Agent can be messaged directly without manually tagging
|
|
23
|
+
- [X] Update Anthropic model to newer one
|
|
24
|
+
- [X] Fix OpenAI Provider
|
|
25
|
+
- [X] Check how many activities results bot fetches, tell him there are more and show him how to fetch more
|
|
26
|
+
- [X] Tell bot what MCP means (not Mission Control Protocol...)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Ideas for agent improvements:
|
|
30
|
+
- [ ] Debug: why are certain fields not filled by agent, if it said it did?
|
|
31
|
+
- [ ] Try to prompt it to fetch the workflow before attempting to set fields.
|
|
32
|
+
- [ ] When using create activity always lookup the available fields of the workflow before adding data
|
|
33
|
+
- [ ] Reason what data should go into what field before adding data to the fields
|
|
34
|
+
- [ ] Use a short and describing name for the activity created if not given a clear instruction by the person who makes the request
|
|
35
|
+
- [X] For all requests preload the 10 last messages from the chat from which the message comes to the context window
|
|
36
|
+
- [X] The agent seems to load only a limited amount of activities when asked how many activities are in a certain phase -> show to agent how many total records OR pagination OR etc
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
This project provides both an **MCP Server** and an **MCP Client** for Hailer integration:
|
|
47
|
+
|
|
48
|
+
- **MCP Server** - Provides Hailer tools to external MCP clients (like Claude Desktop)
|
|
49
|
+
- **MCP Client** - Automated agent that responds to `@mcp-agent` mentions in Hailer chats
|
|
50
|
+
To understand this codebase, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (mermaid support recommended).
|
|
51
|
+
|
|
52
|
+
## Testing with K3D cluster
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
The project uses a **Vite frontend + Express backend** architecture for optimal development experience and proper background service management:
|
|
57
|
+
|
|
58
|
+
- **Backend** (`server/`) - Express server with MCP server and client
|
|
59
|
+
- **Frontend** (`frontend/`) - Vite-powered React interface for tool management
|
|
60
|
+
- **Agent Tracking** - Comprehensive analytics and performance monitoring for AI agents
|
|
61
|
+
- **Benefits**: MCP client starts immediately on server boot (no page loads required!)
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### 1. Install Dependencies
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Backend
|
|
69
|
+
cd server && npm install
|
|
70
|
+
|
|
71
|
+
# Frontend
|
|
72
|
+
cd frontend && npm install
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 2. Environment Configuration
|
|
76
|
+
|
|
77
|
+
The system works out-of-the-box with default local development settings. For custom configuration, create `.env.local` in the `/server` directory (not the project root):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# MCP Client Configuration (enabled by default)
|
|
81
|
+
MCP_CLIENT_ENABLED=true
|
|
82
|
+
|
|
83
|
+
# LLM Provider API Keys
|
|
84
|
+
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key-here
|
|
85
|
+
OPENAI_API_KEY=sk-your-openai-key-here
|
|
86
|
+
|
|
87
|
+
# MCP Agent User IDs (required for agent tagging)
|
|
88
|
+
MCP_CLIENT_AGENT_IDS='["your-mcp-agent-user-id-1", "your-mcp-agent-user-id-2"]'
|
|
89
|
+
|
|
90
|
+
# Custom Hailer Configuration (required for multi-bot setup)
|
|
91
|
+
CLIENT_CONFIGS='[
|
|
92
|
+
{
|
|
93
|
+
"userId": "bot-user-id-1",
|
|
94
|
+
"email": "bot1@example.com",
|
|
95
|
+
"password": "bot1-password",
|
|
96
|
+
"mcpServerApiKey": "unique-api-key-1",
|
|
97
|
+
"apiBaseUrl": "https://api.hailer.com"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"userId": "bot-user-id-2",
|
|
101
|
+
"email": "bot2@example.com",
|
|
102
|
+
"password": "bot2-password",
|
|
103
|
+
"mcpServerApiKey": "unique-api-key-2",
|
|
104
|
+
"apiBaseUrl": "https://api.hailer.com"
|
|
105
|
+
}
|
|
106
|
+
]'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 3. Development
|
|
110
|
+
|
|
111
|
+
**Option A: Development Mode**
|
|
112
|
+
```bash
|
|
113
|
+
# Terminal 1: Start backend (includes MCP client auto-start)
|
|
114
|
+
cd server && npm run dev
|
|
115
|
+
|
|
116
|
+
# Terminal 2: Start frontend dev server
|
|
117
|
+
cd frontend && npm run dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Option B: Production Mode**
|
|
121
|
+
```bash
|
|
122
|
+
# Build frontend
|
|
123
|
+
cd frontend && npm run build
|
|
124
|
+
|
|
125
|
+
# Start backend (serves both API and frontend)
|
|
126
|
+
cd server && npm start
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Usage
|
|
130
|
+
|
|
131
|
+
### MCP Server (Tools for External Clients)
|
|
132
|
+
|
|
133
|
+
Add to Claude Desktop or other MCP clients:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"hailer-mcp": {
|
|
139
|
+
"command": "npx",
|
|
140
|
+
"args": ["mcp-remote", "http://localhost:3030/api/mcp?apiKey=test-key"]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### MCP Client (Automated Agent)
|
|
147
|
+
|
|
148
|
+
**✅ The MCP client now starts automatically when the server boots!**
|
|
149
|
+
|
|
150
|
+
**Setup Steps:**
|
|
151
|
+
1. **Create MCP Agent Profiles** in your Hailer instance (create user profiles for your agents)
|
|
152
|
+
2. **Get the User IDs** of these agent profiles and add them to `MCP_CLIENT_AGENT_IDS`
|
|
153
|
+
3. **Configure bot credentials** in `CLIENT_CONFIGS` with unique `userId` and **unique `mcpServerApiKey`** for each bot
|
|
154
|
+
4. **Configure LLM API keys** (OpenAI or Anthropic)
|
|
155
|
+
5. **Create `.env.local` file** in the `/server` directory (not project root!)
|
|
156
|
+
6. **Start the server** (`npm run dev` in server/)
|
|
157
|
+
7. **Use in Hailer**: Tag/mention your MCP agent profiles in any discussion to trigger the automated agent!
|
|
158
|
+
|
|
159
|
+
**⚠️ IMPORTANT**: Each bot MUST have a unique `mcpServerApiKey` in `CLIENT_CONFIGS`. This is how the MCP server identifies which bot's credentials to use for tool execution.
|
|
160
|
+
|
|
161
|
+
**Multi-Bot Architecture:**
|
|
162
|
+
- Each bot uses its own Hailer credentials and socket connection
|
|
163
|
+
- Each bot has a unique MCP server API key for tool authentication
|
|
164
|
+
- When a bot is mentioned, all MCP tool calls use that bot's credentials
|
|
165
|
+
- Multiple bots can operate simultaneously in different discussions
|
|
166
|
+
|
|
167
|
+
Example: Tag your MCP agent and ask: `list my activities in the Tasks workflow`
|
|
168
|
+
|
|
169
|
+
The agent will:
|
|
170
|
+
- Process your request immediately (no delays!)
|
|
171
|
+
- Call appropriate MCP tools (`list_activities`, etc.)
|
|
172
|
+
- Respond back in the chat with results
|
|
173
|
+
|
|
174
|
+
## Troubleshooting
|
|
175
|
+
|
|
176
|
+
**Problem: Bot uses wrong credentials for tool execution**
|
|
177
|
+
- **Solution**: Ensure each bot has a unique `mcpServerApiKey` in `CLIENT_CONFIGS`
|
|
178
|
+
- **Check**: Look for "✅ MCP Config: Using credentials for..." in server logs
|
|
179
|
+
|
|
180
|
+
**Problem: Messages processed multiple times**
|
|
181
|
+
- **Solution**: The system now includes message deduplication
|
|
182
|
+
- **Check**: Look for "🔄 MCP Client: Message ... already processed, skipping"
|
|
183
|
+
|
|
184
|
+
**Problem: Bot doesn't respond to mentions**
|
|
185
|
+
- **Check**: Verify bot user IDs are in `MCP_CLIENT_AGENT_IDS`
|
|
186
|
+
- **Check**: Ensure `.env.local` is in `/server` directory, not project root
|
|
187
|
+
- **Check**: Look for "✅ MCP Client: Found mention of bot: ..." in logs
|
|
188
|
+
|
|
189
|
+
## Available Providers
|
|
190
|
+
|
|
191
|
+
- **Anthropic Claude** (`anthropic-claude`) - Uses Claude 3.5 Sonnet with MCP tool integration
|
|
192
|
+
- **OpenAI GPT** (`openai-gpt4o`) - Uses GPT-4o with OpenAI's native MCP support
|
|
193
|
+
|
|
194
|
+
The system automatically uses the first available provider based on configured API keys.
|
|
195
|
+
|
|
196
|
+
## Development Tools
|
|
197
|
+
|
|
198
|
+
### Web Interface
|
|
199
|
+
|
|
200
|
+
Visit `http://localhost:3030` (production) or `http://localhost:3031` (development) to access:
|
|
201
|
+
|
|
202
|
+
- **Tools page**: Browse and test all available MCP tools
|
|
203
|
+
- **Activity page**: Monitor agent performance, success rates, and conversation flows
|
|
204
|
+
- **Feedback page**: Development feedback interface
|
|
205
|
+
|
|
206
|
+
### Agent Analytics
|
|
207
|
+
|
|
208
|
+
The system includes comprehensive agent activity tracking that captures:
|
|
209
|
+
- **Conversation flows**: Complete trigger → completion correlation with request IDs
|
|
210
|
+
- **Performance metrics**: Success rates, response times, and tool usage statistics
|
|
211
|
+
- **Tool analytics**: Detailed request/response data for every tool call
|
|
212
|
+
- **Environment-aware**: JSON files in development, OTLP logging in production
|
|
213
|
+
|
|
214
|
+
View analytics via `/activity` endpoint or programmatically via `src/client/agent-tracker.ts`.
|
|
215
|
+
|
|
216
|
+
### Claude Code Integration
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Add MCP server to Claude Code
|
|
220
|
+
claude mcp add -s project hailer npx mcp-remote "http://localhost:3030/api/mcp?apiKey=test-key"
|
|
221
|
+
|
|
222
|
+
# Remove MCP server
|
|
223
|
+
claude mcp remove -s project hailer
|
|
224
|
+
|
|
225
|
+
# Debug mode
|
|
226
|
+
claude --debug
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### MCP Inspector
|
|
230
|
+
|
|
231
|
+
Use the official [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for direct tool testing:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npx @modelcontextprotocol/inspector http://localhost:3030/api/mcp?apiKey=test-key
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Configuration Examples
|
|
238
|
+
|
|
239
|
+
### Basic Setup (Anthropic)
|
|
240
|
+
```bash
|
|
241
|
+
# .env.local
|
|
242
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
243
|
+
MCP_CLIENT_ENABLED=true
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Multi-Provider Setup
|
|
247
|
+
```bash
|
|
248
|
+
# .env.local
|
|
249
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
250
|
+
OPENAI_API_KEY=sk-your-openai-key
|
|
251
|
+
MCP_CLIENT_ENABLED=true
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Custom Hailer Instance
|
|
255
|
+
```bash
|
|
256
|
+
# .env.local
|
|
257
|
+
ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
258
|
+
CLIENT_CONFIGS='[{"email":"you@company.com","password":"yourpassword","mcpServerApiKey":"custom-key","apiBaseUrl":"https://your-hailer.com"}]'
|
|
259
|
+
MCP_CLIENT_ENABLED=true
|
|
260
|
+
MCP_CLIENT_API_KEY=custom-key
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Troubleshooting
|
|
264
|
+
|
|
265
|
+
### MCP Client Not Responding
|
|
266
|
+
- Check that API keys are configured correctly
|
|
267
|
+
- Verify the backend server is running (`npm run dev` in `server/`)
|
|
268
|
+
- Check logs for provider initialization messages
|
|
269
|
+
|
|
270
|
+
### MCP Server Connection Issues
|
|
271
|
+
- Ensure the server is accessible at the configured URL
|
|
272
|
+
- For external MCP clients, the server must be publicly accessible (not localhost)
|
|
273
|
+
- Use ngrok or similar for testing with external services
|
|
274
|
+
|
|
275
|
+
### Signal Processing Issues
|
|
276
|
+
- The MCP client processes `messenger.new` signals from Hailer
|
|
277
|
+
- Verify socket.io connection is established in server logs
|
|
278
|
+
- Check that the Hailer instance supports real-time signals
|
|
279
|
+
|
|
280
|
+
## What's New
|
|
281
|
+
|
|
282
|
+
### ✅ Immediate Background Services
|
|
283
|
+
- **Fixed**: MCP client now starts immediately on server boot
|
|
284
|
+
- **No more**: Waiting for page loads to initialize background services
|
|
285
|
+
- **Benefit**: `@mcp-agent` mentions work instantly
|
|
286
|
+
|
|
287
|
+
### ✅ Modern Development Stack
|
|
288
|
+
- **Frontend**: Vite + React (faster than Next.js)
|
|
289
|
+
- **Backend**: Express (lighter than Next.js)
|
|
290
|
+
- **Architecture**: Clean separation of concerns
|
|
291
|
+
|
|
292
|
+
### ✅ Enhanced Provider Support
|
|
293
|
+
- **Anthropic Claude**: Full MCP tool integration
|
|
294
|
+
- **OpenAI GPT**: Native MCP support via Responses API
|
|
295
|
+
- **Auto-detection**: Uses first available provider
|
|
296
|
+
|
|
297
|
+
All existing functionality is preserved while providing a much better development experience!
|
package/dist/app.d.ts
ADDED
package/dist/app.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("./core");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const file_1 = require("./mcp/tools/file");
|
|
6
|
+
const activity_1 = require("./mcp/tools/activity");
|
|
7
|
+
const discussion_1 = require("./mcp/tools/discussion");
|
|
8
|
+
const user_1 = require("./mcp/tools/user");
|
|
9
|
+
const workflow_1 = require("./mcp/tools/workflow");
|
|
10
|
+
const insight_1 = require("./mcp/tools/insight");
|
|
11
|
+
const app_1 = require("./mcp/tools/app");
|
|
12
|
+
const skill_1 = require("./mcp/tools/skill");
|
|
13
|
+
const core = new core_1.Core();
|
|
14
|
+
console.log('Registering tools...');
|
|
15
|
+
console.log(`Nuclear tools ${config_1.environment.ENABLE_NUCLEAR_TOOLS ? 'ENABLED' : 'DISABLED'} (set ENABLE_NUCLEAR_TOOLS=true in .env.local to enable)`);
|
|
16
|
+
core.addTool(file_1.uploadFilesTool);
|
|
17
|
+
core.addTool(activity_1.listActivitiesTool);
|
|
18
|
+
core.addTool(activity_1.showActivityByIdTool);
|
|
19
|
+
core.addTool(activity_1.createActivityTool);
|
|
20
|
+
core.addTool(activity_1.updateActivityTool);
|
|
21
|
+
// core.addTool(searchActivitiesTool);
|
|
22
|
+
// core.addTool(filterActivitiesTool);
|
|
23
|
+
// core.addTool(activityToolsGuideTool);
|
|
24
|
+
core.addTool(discussion_1.listMyDiscussionsTool);
|
|
25
|
+
core.addTool(discussion_1.fetchDiscussionMessagesTool);
|
|
26
|
+
core.addTool(discussion_1.fetchPreviousDiscussionMessagesTool);
|
|
27
|
+
core.addTool(discussion_1.joinDiscussionTool);
|
|
28
|
+
core.addTool(discussion_1.leaveDiscussionTool);
|
|
29
|
+
core.addTool(discussion_1.addDiscussionMessageTool);
|
|
30
|
+
core.addTool(discussion_1.inviteDiscussionMembersTool);
|
|
31
|
+
core.addTool(discussion_1.getActivityFromDiscussionTool);
|
|
32
|
+
core.addTool(user_1.searchWorkspaceUsersTool);
|
|
33
|
+
// core.addTool(hailerGetInitTool);
|
|
34
|
+
// core.addTool(validateUserIdTool);
|
|
35
|
+
core.addTool(workflow_1.getWorkflowSchemaTool);
|
|
36
|
+
core.addTool(workflow_1.listWorkflowPhasesTool);
|
|
37
|
+
core.addTool(workflow_1.listWorkflowsTool);
|
|
38
|
+
core.addTool(workflow_1.installWorkflowTool);
|
|
39
|
+
if (config_1.environment.ENABLE_NUCLEAR_TOOLS) {
|
|
40
|
+
core.addTool(workflow_1.removeWorkflowTool);
|
|
41
|
+
}
|
|
42
|
+
core.addTool(workflow_1.updateWorkflowFieldTool);
|
|
43
|
+
core.addTool(workflow_1.updateWorkflowPhaseTool);
|
|
44
|
+
core.addTool(workflow_1.testFunctionFieldTool);
|
|
45
|
+
core.addTool(workflow_1.listWorkflowsMinimalTool);
|
|
46
|
+
core.addTool(workflow_1.countActivitiesTool);
|
|
47
|
+
core.addTool(insight_1.createInsightTool);
|
|
48
|
+
core.addTool(insight_1.previewInsightTool);
|
|
49
|
+
core.addTool(insight_1.getInsightDataTool);
|
|
50
|
+
if (config_1.environment.ENABLE_NUCLEAR_TOOLS) {
|
|
51
|
+
core.addTool(insight_1.removeInsightTool);
|
|
52
|
+
}
|
|
53
|
+
core.addTool(insight_1.listInsightsTool);
|
|
54
|
+
core.addTool(app_1.createAppTool);
|
|
55
|
+
core.addTool(app_1.listAppsTool);
|
|
56
|
+
core.addTool(app_1.updateAppTool);
|
|
57
|
+
if (config_1.environment.ENABLE_NUCLEAR_TOOLS) {
|
|
58
|
+
core.addTool(app_1.removeAppTool);
|
|
59
|
+
}
|
|
60
|
+
core.addTool(app_1.addAppMemberTool);
|
|
61
|
+
core.addTool(app_1.removeAppMemberTool);
|
|
62
|
+
core.addTool(app_1.scaffoldHailerAppTool);
|
|
63
|
+
core.addTool(app_1.publishHailerAppTool);
|
|
64
|
+
core.addTool(skill_1.listSkillsTool);
|
|
65
|
+
core.addTool(skill_1.getSkillTool);
|
|
66
|
+
console.log('All tools registered successfully!');
|
|
67
|
+
// Start the application
|
|
68
|
+
core.start().catch((error) => {
|
|
69
|
+
console.error('Failed to start Hailer MCP application:', error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
// Export core for testing and external access
|
|
73
|
+
exports.default = core;
|
|
74
|
+
//# sourceMappingURL=app.js.map
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Documentation Bot
|
|
3
|
+
*
|
|
4
|
+
* Monitors MCP logs for tool call errors and automatically improves
|
|
5
|
+
* tool descriptions and skills based on actual LLM usage patterns.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Detects when LLMs make mistakes calling tools
|
|
9
|
+
* - Uses LLM to analyze what went wrong
|
|
10
|
+
* - Automatically updates tool descriptions
|
|
11
|
+
* - Creates/updates skill documents with common mistakes
|
|
12
|
+
* - Learns and improves over time
|
|
13
|
+
*/
|
|
14
|
+
import { ToolCallError, ErrorPattern, AdaptiveBotConfig } from './adaptive-documentation-types';
|
|
15
|
+
export declare class AdaptiveDocumentationBot {
|
|
16
|
+
private logParser;
|
|
17
|
+
private descriptionUpdater;
|
|
18
|
+
private skillGenerator;
|
|
19
|
+
private llmCaller;
|
|
20
|
+
private config;
|
|
21
|
+
private errorPatterns;
|
|
22
|
+
private monitoringInterval?;
|
|
23
|
+
private isMonitoring;
|
|
24
|
+
constructor(apiKey: string, provider?: 'anthropic' | 'openai', config?: Partial<AdaptiveBotConfig>);
|
|
25
|
+
/**
|
|
26
|
+
* Start monitoring logs for errors
|
|
27
|
+
*/
|
|
28
|
+
startMonitoring(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Analyze logs immediately after a conversation ends
|
|
31
|
+
* Called by MCP Client after each bot conversation
|
|
32
|
+
*/
|
|
33
|
+
analyzeAfterConversation(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Report error directly (not from logs)
|
|
36
|
+
* Use this to capture errors from active conversations
|
|
37
|
+
*/
|
|
38
|
+
reportError(error: ToolCallError): void;
|
|
39
|
+
/**
|
|
40
|
+
* Stop monitoring logs
|
|
41
|
+
*/
|
|
42
|
+
stopMonitoring(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Main monitoring loop: parse errors and apply improvements
|
|
45
|
+
*/
|
|
46
|
+
private monitorAndImprove;
|
|
47
|
+
/**
|
|
48
|
+
* Update error patterns with new errors
|
|
49
|
+
*/
|
|
50
|
+
private updateErrorPatterns;
|
|
51
|
+
/**
|
|
52
|
+
* Analyze error pattern and apply improvements
|
|
53
|
+
*/
|
|
54
|
+
private analyzeAndImprove;
|
|
55
|
+
/**
|
|
56
|
+
* Analyze error pattern using LLM
|
|
57
|
+
*/
|
|
58
|
+
private analyzeWithLLM;
|
|
59
|
+
/**
|
|
60
|
+
* Apply improvements based on analysis
|
|
61
|
+
*/
|
|
62
|
+
private applyImprovements;
|
|
63
|
+
/**
|
|
64
|
+
* Generate improved description using LLM
|
|
65
|
+
*/
|
|
66
|
+
private generateImprovedDescription;
|
|
67
|
+
/**
|
|
68
|
+
* Generate improved parameter description using LLM
|
|
69
|
+
*/
|
|
70
|
+
private generateImprovedParameterDescription;
|
|
71
|
+
/**
|
|
72
|
+
* Generate pattern key for grouping similar errors
|
|
73
|
+
*/
|
|
74
|
+
private getPatternKey;
|
|
75
|
+
/**
|
|
76
|
+
* Generate human-readable description for error pattern
|
|
77
|
+
*/
|
|
78
|
+
private generatePatternDescription;
|
|
79
|
+
/**
|
|
80
|
+
* Get statistics about adaptive bot performance
|
|
81
|
+
*/
|
|
82
|
+
getStats(): {
|
|
83
|
+
monitoring: boolean;
|
|
84
|
+
errorPatterns: number;
|
|
85
|
+
improvements: any;
|
|
86
|
+
skills: any;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Get error patterns for a specific tool
|
|
90
|
+
*/
|
|
91
|
+
getToolErrorPatterns(toolName: string): ErrorPattern[];
|
|
92
|
+
/**
|
|
93
|
+
* Test mode - parse errors and show what would be improved (without applying changes)
|
|
94
|
+
*/
|
|
95
|
+
testRun(): Promise<{
|
|
96
|
+
errors: ToolCallError[];
|
|
97
|
+
patterns: ErrorPattern[];
|
|
98
|
+
suggestions: Array<{
|
|
99
|
+
toolName: string;
|
|
100
|
+
errorCount: number;
|
|
101
|
+
errorMessage: string;
|
|
102
|
+
existingSkill?: string;
|
|
103
|
+
wouldCreateSkill: boolean;
|
|
104
|
+
wouldUpdateSkill: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
}>;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=adaptive-documentation-bot.d.ts.map
|