Commit Graph

180 Commits

Author SHA1 Message Date
Ed Zynda ce32cea7ee feat: upgrade charmbracelet libs to v2 (bubbletea, lipgloss, bubbles)
Migrate from github.com/charmbracelet/* v1 to charm.land/* v2 vanity imports.

Key changes:
- bubbletea: View() returns tea.View, KeyMsg -> KeyPressMsg, msg.String() matching
- lipgloss: AdaptiveColor replaced with cached dark-bg detection helper
- bubbles/textarea: Styles()/SetStyles() pattern, KeyMap.InsertNewline override
- bubbles/progress: SetWidth(), WithDefaultBlend(), typed Update return
- Input: enter always submits, ctrl+j/alt+enter insert newlines
- User message newlines preserved through glamour via \n -> \n\n conversion
- glamour stays at v1 (no v2 exists)
2026-02-25 17:07:09 +03:00
Ed Zynda d24d49854f Merge branch 'main' of github.com:mark3labs/mcphost 2026-02-25 16:24:33 +03:00
Ed Zynda bf2f44190d btca 2026-02-25 16:24:28 +03:00
Ramiz Polic 191dcea159 chore: update packages to resolve security issues (#154)
Signed-off-by: Ramiz Polic <rpolic@cisco.com>
2026-02-15 19:56:44 +03:00
Ed Zynda a77aab3d90 fix: upgrade sonic to v1.15.0 for Go 1.26 compatibility
Fixes build error with Go 1.26rc1/rc2 caused by undefined GoMapIterator
in sonic v1.14.1.

Closes #152
2026-02-02 11:09:51 +03:00
Shane McDonald c4aa911e3a feat: add Google Vertex AI support for Claude models (#146)
Add support for using Claude models via Google Cloud Vertex AI through
the `google-vertex-anthropic` provider. This enables users who have
Claude access through their Google Cloud account to use mcphost with
Vertex AI authentication.

Changes:
- Add `google-vertex-anthropic` provider case and createVertexAnthropicProvider()
- Support multiple env var names for project/region to match eino-claude:
  - Project: ANTHROPIC_VERTEX_PROJECT_ID, GOOGLE_CLOUD_PROJECT, GCLOUD_PROJECT
  - Region: CLOUD_ML_REGION (defaults to "global" if not set)
- Upgrade eino from v0.5.11 to v0.7.11 (required by eino-claude v0.1.12)
- Migrate schema API from OpenAPI v3 to JSON Schema (eino v0.7.11 change)

Usage:
  # Authenticate with Google Cloud
  gcloud auth application-default login

  # Set required environment variables
  export ANTHROPIC_VERTEX_PROJECT_ID="your-project-id"
  export CLOUD_ML_REGION="us-east5"  # or use default "global"

  # Run mcphost
  mcphost --model google-vertex-anthropic:claude-sonnet-4@20250514

Reference: https://docs.anthropic.com/en/docs/claude-code/google-vertex-ai

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 13:01:18 +03:00
Ed Zynda 7ece291d9a fix anthropic api issue 2026-01-09 17:39:30 +03:00
Ed Zynda f9485cbe59 new models 2026-01-09 17:30:59 +03:00
Ed Zynda c284a20dab upgrade deps 2026-01-09 17:25:53 +03:00
Cory LaNou 1b3a8c171a fix: convert JSON Schema draft-07 exclusive bounds to draft-04 format (#147)
* fix: convert JSON Schema draft-07 exclusive bounds to draft-04 format

Chrome DevTools MCP and other MCP servers use JSON Schema draft-07 where
exclusiveMinimum/exclusiveMaximum are numeric values representing the
actual bounds. However, kin-openapi (OpenAPI 3.0) expects these fields
as booleans that modify the minimum/maximum values (draft-04 format).

This fix recursively processes input schemas to convert:
- exclusiveMinimum: N → minimum: N, exclusiveMinimum: true
- exclusiveMaximum: N → maximum: N, exclusiveMaximum: true

Handles nested schemas in properties, items, additionalProperties,
and schema composition keywords (allOf, anyOf, oneOf, not).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add table-driven tests for JSON Schema draft conversion

Adds comprehensive tests for convertExclusiveBoundsToBoolean():
- Simple exclusiveMinimum/exclusiveMaximum conversion
- Both bounds together
- Already boolean values (draft-04 style, unchanged)
- No exclusive bounds (unchanged)
- Nested properties
- Array items
- allOf composition
- additionalProperties
- Real-world Chrome DevTools MCP schema example
- Invalid JSON handling (returns unchanged)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:03:16 +03:00
Ed Zynda 4891f87038 skip unless running locally 2025-12-09 21:27:48 +03:00
Darragh O'Reilly f240b9a8c1 Bump github.com/cloudwego/eino to fix panic (#142)
Fixes panic when using some MCP servers that were auto-generated
from OpenAPI specs. Fixes #141
2025-12-09 18:28:52 +03:00
Darragh O'Reilly cab31935f1 Feat: Add option to require approval before tool execution (#140)
Adds a new CLI option, `--approve-tool-run` (or via config setting),
that when enabled, prompts the user to approve a tool's execution
before it runs.

This option is disabled by default to maintain existing behavior.
2025-12-09 18:28:41 +03:00
Ed Zynda d3cae7c016 remove stale key 2025-12-05 10:25:49 +03:00
Ed Zynda 8c1f548eac update deps 2025-11-14 17:06:07 +03:00
Ed Zynda 63704f55b5 godoc 2025-11-12 16:48:46 +03:00
Ed Zynda d3281a2f01 format 2025-10-16 16:36:12 +03:00
Ed Zynda 1b7cc2ef6e update models 2025-10-16 16:35:52 +03:00
Ed Zynda d56335e807 fix: suppress health check logging to debug output only (#135)
Replace fmt.Printf calls in connection pool health check routines with debug logger calls. Health check messages are now only displayed when the --debug flag is enabled, providing a cleaner terminal output during normal operation while maintaining diagnostic information for troubleshooting.
2025-10-16 16:33:41 +03:00
Ed Zynda 13acf44131 add AGENTS.md 2025-10-16 16:26:19 +03:00
Ed Zynda dec5f08f80 update mcp-go 2025-10-07 10:35:31 +03:00
Ed Zynda 81ec644cb9 Update deps 2025-09-03 15:45:02 +03:00
Ed Zynda f778379dea feat: Add SDK package for programmatic MCPHost usage (#129)
* feat: add SDK package for programmatic MCPHost usage

- Export InitConfig and LoadConfigWithEnvSubstitution from cmd package
- Create sdk package with MCPHost type for programmatic access
- Add Options struct for configuration overrides
- Implement Prompt and PromptWithCallbacks methods
- Add session management (load, save, clear)
- Create type helpers for Message and ToolCall
- Add comprehensive SDK documentation in README
- Include basic and scripting examples
- Add unit tests for SDK functionality

The SDK reuses all existing internal packages and maintains identical
behavior to the CLI, including config loading, environment variables,
and defaults.

* docs: add SDK section to main README with link to detailed documentation

* fix tests

* update CI
2025-09-02 15:42:37 +03:00
Ed Zynda 4709716f5e Let viper handle precedence 2025-09-02 15:10:03 +03:00
Rui Chen 433bdece70 fix --version output (#128)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2025-09-02 13:53:37 +03:00
Ed Zynda cc1ab91e64 Update mcp-go 2025-09-02 13:46:31 +03:00
matscalia 4efc2e271c Theme config (#127)
* add theme configuration

* add path for themes (broken)

* md theme relative path not working

* cleanup malpractice

* mid commit

* fix logical error
2025-09-02 10:30:20 +03:00
Ed Zynda 4f2f61c673 Update mcp-go 2025-08-11 20:21:05 +03:00
matscalia bce9221916 Session flag (#123)
* add session flag for convenience

* add short version

* fix logical error

* create session file if not present
2025-08-11 20:13:06 +03:00
matscalia d3c04b12bc add ollama api key (#124) 2025-08-11 20:10:32 +03:00
Ed Zynda 2f428997b3 Use fang 2025-08-11 20:10:20 +03:00
Štefan Baebler 4808ed2138 Upgrade github.com/bytedance/sonic to v1.14.0 for Go 1.25 support (#122)
Fixes #121

$ go get github.com/bytedance/sonic@latest && go mod tidy
go: upgraded github.com/bytedance/sonic v1.13.3 => v1.14.0
go: upgraded github.com/bytedance/sonic/loader v0.2.4 => v0.3.0
2025-08-10 13:49:03 +07:00
Ed Zynda d3f9759eb4 refactor debug messages 2025-08-08 09:32:04 +03:00
Ed Zynda 5d83df457b update models 2025-08-08 08:02:21 +03:00
Shancang 76741ab037 Feature/add connection pool (#120)
* feat: add MCP connection pool with health check and retry mechanism

* feat: add proactive connection health check before tool calls

- Add GetConnectionWithHealthCheck method to perform health check before reusing connections
- Add performHealthCheck method to test connection health with ListTools call
- Modify InvokableRun to use health-checked connections
- This prevents first tool call failure when connection is broken
- Improves user experience by ensuring connections are healthy before tool execution

---------

Co-authored-by: 茂勋 <shancangchen.csc@alibaba-inc.com>
2025-08-05 17:01:12 +03:00
Ed Zynda fe4db1998d feat: add --tls-skip-verify flag for self-signed certificates (#115)
* feat: add --tls-skip-verify flag for self-signed certificates

Adds support for skipping TLS certificate verification when connecting to
providers with self-signed certificates. This is particularly useful for
local Ollama instances secured with HTTPS.

- Add --tls-skip-verify command-line flag with security warnings
- Update ProviderConfig to include TLSSkipVerify field
- Modify HTTP client creation for all providers (Ollama, OpenAI, Anthropic, Google, Azure)
- Create helper functions for TLS-aware HTTP client creation
- Add comprehensive unit tests for TLS skip verify functionality
- Update documentation with usage examples and security warnings

Fixes #113

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* feat: add TLS skip verify support to script mode

- Add TLSSkipVerify field to Config struct for script frontmatter
- Update script parsing to handle tls-skip-verify in YAML frontmatter
- Pass TLS configuration to model creation in script mode
- Add example script demonstrating TLS skip verify usage
- Update script examples documentation

This allows scripts to specify tls-skip-verify: true in their frontmatter
to connect to providers with self-signed certificates.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

---------

Co-authored-by: opencode <noreply@opencode.ai>
2025-08-05 17:00:58 +03:00
Ed Zynda d30f15269e feat: enhance hooks with LLM feedback capabilities (#112)
* feat: enhance hooks with LLM feedback capabilities

- Add new HookOutput fields for LLM interaction (feedback, context, systemPrompt, modifyInput/Output)
- Implement Continue functionality to gracefully stop sessions from hooks
- Implement SuppressOutput to hide tool results from user display
- Add UserPromptSubmit context injection to provide additional context to LLM
- Update mergeHookOutputs to handle new fields
- Add comprehensive unit tests for new hook output processing
- Create example Python hook demonstrating LLM feedback features

This enhancement allows hooks to:
- Provide feedback and context that reaches the LLM
- Modify tool inputs/outputs before processing
- Control session flow with Continue field
- Suppress output display while still sending to LLM
- Inject system prompts and context for better LLM responses

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* fix: make tool blocking visible to LLM

When a PreToolUse hook blocks a tool execution, the LLM now receives an error message
indicating the tool was blocked, allowing it to adapt its approach.

Changes:
- Track when tools are blocked by PreToolUse hooks
- Replace tool execution results with error messages when blocked
- Add test to verify blocking functionality
- Add ToolBlockChecker type for future enhancements

This ensures the LLM is aware when its tool calls are blocked by security policies
and can respond appropriately rather than being unaware of the block.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* refactor: remove unimplemented LLM feedback fields

Removed the following unimplemented fields from HookOutput:
- Feedback
- Context
- SystemPrompt
- ModifyInput
- ModifyOutput

These fields were added speculatively but not fully implemented.
Keeping only the working functionality:
- Continue/StopReason for session control
- SuppressOutput for hiding tool results
- Decision/Reason for blocking tools

The critical tool blocking visibility feature remains intact.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

---------

Co-authored-by: opencode <noreply@opencode.ai>
2025-07-24 15:54:29 +03:00
Ed Zynda 0211e9ff7e update README 2025-07-24 14:03:15 +03:00
Ed Zynda cdc4abfb36 Add comprehensive hooks system for MCPHost lifecycle events (#111)
* Add comprehensive hooks system for MCPHost lifecycle events

Implements a flexible hooks system based on Anthropic Claude Code specification:

- **Hook Events**: PreToolUse, PostToolUse, UserPromptSubmit, Stop
- **Hook Types**: Command execution with JSON input/output
- **Configuration**: XDG-compliant with layered config support
- **Security**: Command validation, timeout controls, safe execution
- **Common Fields**: Consistent session ID, timestamps, model info across all hooks

Key features:
- Hooks receive JSON via stdin and can control flow via stdout
- Pattern matching for tool-specific hooks (regex support)
- Enhanced Stop hook with agent response and metadata
- Centralized session management with consistent IDs
- Built-in examples for logging, validation, and monitoring

This enables users to:
- Log and audit all tool usage and prompts
- Implement custom security policies
- Track usage metrics and model performance
- Integrate with external systems
- Build custom workflows around MCPHost

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* Enable hooks in script mode

Previously, hooks were only initialized and executed in normal mode but not
in script mode. This was because script mode had its own execution path that
bypassed the hook initialization code.

This fix:
- Adds hook initialization to runScriptMode function
- Creates hook executor with proper session ID and model info
- Passes the hook executor to runAgenticLoop

Now hooks work consistently across all execution modes (normal, script, and
interactive), ensuring uniform behavior for logging, validation, and monitoring.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* Remove unnecessary hooks.local.yml pattern

The .local.yml pattern adds unnecessary complexity. Users who want project-specific
hooks that aren't committed to git can simply add .mcphost/ to their .gitignore.

This simplifies the hooks configuration loading and makes it clearer that:
- Global user hooks go in ~/.config/mcphost/hooks.yml
- Project-specific hooks go in .mcphost/hooks.yml
- Git ignore management is left to the user

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

* Fix hooks test isolation and add --no-hooks flag

- Fix TestLoadHooksConfig by setting temporary XDG_CONFIG_HOME to prevent loading global hooks
- Add --no-hooks flag to disable all hooks execution across all modes
- Update README with documentation for the new flag
- Add test to verify hooks loading behavior

This allows users to temporarily disable hooks for security or debugging purposes.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>

---------

Co-authored-by: opencode <noreply@opencode.ai>
2025-07-24 13:56:33 +03:00
Ed Zynda 66b7a72281 fix env parsing 2025-07-22 18:53:44 +03:00
Karsten Ohme 4227926dda Sanitize tool arguments to handle empty or malformed input (#110) 2025-07-21 16:52:57 +03:00
Ed Zynda e40e44da48 add fetch_filtered_json tool 2025-07-16 13:59:42 +03:00
Ed Zynda 2fd34068dd fix tests 2025-07-15 14:41:44 +03:00
Ed Zynda df9337d085 fix script frontmatter parsing 2025-07-15 14:27:58 +03:00
Ed Zynda f3fd2822de add fetch_extract tool 2025-07-15 13:43:03 +03:00
Ed Zynda b0761f7ada add fetch_summarize tool 2025-07-15 13:35:18 +03:00
Ed Zynda 8eb5060dc4 Add builtin HTTP functionality (#106)
* Add builtin HTTP functionality

* Add GitHub Actions CI workflow

- Runs tests with race detection on push to main and PRs
- Verifies code generation is up to date
- Uses Go version from go.mod file
- Supports manual workflow dispatch

* Remove verify-codegen job from CI workflow

Simplifies CI to only run tests with race detection
2025-07-10 09:41:51 +03:00
Ed Zynda 5c041394b8 Autocomplete (#105)
* implement autocomplete

* fix

* fix

* remove useless history command

* fix spacing

* fix padding for goodbye

* cleanup
2025-07-09 17:49:13 +03:00
Ed Zynda df29dc1673 fix frontmatter parsing 2025-07-09 12:58:16 +03:00
Ed Zynda a87c772fd0 fix session saving 2025-07-09 11:31:35 +03:00