754 Commits

Author SHA1 Message Date
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
Ed Zynda 9159f226f4 Smooth UI (#104)
* draft: rewrite single message when streaming (not full terminal)

* having the spinner align better with dots in compact mode

* fix user messages

* handle usage display

* fix formatting

* bash highlighting

---------

Co-authored-by: Nate Woods <big.nate.w@gmail.com>
2025-07-09 00:41:35 +03:00
Ed Zynda ac954068a9 update todos 2025-06-30 17:13:12 +03:00
Ed Zynda 4f524d3b16 Fix compact mode in scripts 2025-06-28 14:36:35 +03:00
Ed Zynda 32c46e4dc3 Fix for anthropic 2025-06-28 14:17:53 +03:00
Ed Zynda 053e6c32b0 Fix for openai (#95) 2025-06-28 13:38:58 +03:00
Ed Zynda ddd7856f9b Refactor: Extract shared code between normal and script modes (#94)
This commit addresses issue #92 by extracting duplicated code between
normal mode (cmd/root.go) and script mode (cmd/script.go) into reusable
factory functions and utilities.

## Changes Made

### New Factory Files
- **internal/agent/factory.go**: Agent creation factory with spinner support
  - `CreateAgent()` function with configurable options
  - `ParseModelName()` utility for model string parsing
  - Spinner function injection to avoid import cycles

- **internal/ui/factory.go**: CLI setup factory with standard configuration
  - `SetupCLI()` function for consistent CLI initialization
  - Usage tracking setup for supported providers
  - Model info and tool count display

- **internal/config/merger.go**: Config loading and merging utilities
  - `LoadAndValidateConfig()` for standard config loading
  - `MergeConfigs()` for script frontmatter merging

### Updated Command Files
- **cmd/root.go**: Refactored to use new factories
  - Replaced ~50 lines of agent creation logic
  - Replaced ~30 lines of CLI setup logic
  - Replaced ~20 lines of config loading logic
  - Added agentUIAdapter to handle interface compatibility

- **cmd/script.go**: Refactored to use new factories
  - Same factory usage as normal mode for consistency
  - Maintained script-specific behavior (no spinners)
  - Improved config merging with frontmatter

## Benefits
- **Reduced code duplication**: ~33 lines of duplicated code eliminated
- **Single source of truth**: Agent creation and CLI setup logic centralized
- **Consistent behavior**: Both modes now use identical underlying logic
- **Easier maintenance**: Changes apply to both modes automatically
- **Better testability**: Factory functions can be unit tested independently
- **Cleaner command files**: Focus on mode-specific logic only

## Testing
- All existing tests pass
- Build verification successful
- Both normal and script modes tested for basic functionality
- Code formatting and linting checks passed

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

Co-authored-by: opencode <noreply@opencode.ai>
2025-06-27 17:41:18 +03:00
Ed Zynda 47718a7fed stream in script mode 2025-06-27 16:40:42 +03:00
Ed Zynda 7b2592bbdc fmt 2025-06-27 16:31:01 +03:00
Ed Zynda 00aa3c6995 Env substitution (#93)
* compact mode

* tweaks

* tweaks

* tweaks

* fix streaming in tool calls

* impl env sub

* fix
2025-06-27 16:30:18 +03:00
Ed Zynda 76dd18030a Compact mode (#91)
* compact mode

* tweaks

* tweaks

* tweaks

* fix streaming in tool calls
2025-06-27 15:56:09 +03:00
Ed Zynda 42af56963f remove redundant info 2025-06-27 12:00:23 +03:00
Ed Zynda be5af5469f fix tool output 2025-06-27 11:54:17 +03:00
Ed Zynda 6a1b2f65d1 fix google/gemini 2025-06-27 11:40:11 +03:00
Ed Zynda acade83e37 fix token tracking 2025-06-27 11:33:44 +03:00
Ed Zynda daf5c41ac9 Fix object schema missing properties error for tools without input parameters (#90)
Fixes #89: Tools created without input properties were causing OpenAI function
calling validation errors with "object schema missing properties" message.

The issue occurred when MCP tools had no input parameters, resulting in OpenAPI
schemas with Type="object" but Properties=nil, which violates OpenAI's function
calling schema requirements.

Changes:
- Add schema validation fix in loadServerTools to ensure object schemas have
  empty properties map when Properties is nil
- Add comprehensive regression test TestIssue89_ObjectSchemaMissingProperties
- Add additional test coverage for tools without properties

The fix ensures backward compatibility while resolving the validation error.
Users no longer need the workaround of adding dummy parameters to their tools.

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

Co-authored-by: opencode <noreply@opencode.ai>
2025-06-26 21:33:36 +03:00
Ed Zynda ec620e4e88 Streaming (#87)
* basic streaming

* fix output

* update

* update

* fix display issue

* update readme

* fmt

* cleanup

* cleanup

* cleanup

* fix
2025-06-26 18:15:17 +03:00
Ed Zynda a66c55e175 Improve Ollama and GPU handling (#85)
* preload ollama models

* fix num-gpu

* add download progress bar for ollama models

* fmt

* reorg
2025-06-26 13:32:18 +03:00
dependabot[bot] 6219b84937 Bump github.com/getkin/kin-openapi from 0.118.0 to 0.131.0 (#83)
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.118.0 to 0.131.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](https://github.com/getkin/kin-openapi/compare/v0.118.0...v0.131.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-version: 0.131.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-26 11:50:03 +03:00
Ed Zynda 30f720ef7b updates 2025-06-26 10:56:10 +03:00
Ed Zynda b3c26150c7 fix /clear 2025-06-26 10:49:39 +03:00
Ed Zynda 904cbc6b37 Implement saved sessions (#82) 2025-06-25 20:25:14 +03:00
Ed Zynda b56fb3c597 Merge branch 'main' of github.com:mark3labs/mcphost 2025-06-25 18:18:44 +03:00
Ed Zynda 4d543da3b9 version support 2025-06-25 18:18:29 +03:00
Ed Zynda 7d6abbf4a0 UI updates (#80)
* ui updates

* catppuccin

* fmt
2025-06-25 17:24:37 +03:00
Ed Zynda b25bda58ab update README 2025-06-25 15:02:23 +03:00
Ed Zynda a2346721cb Claude max (#78)
* anthropic oauth

* update claude oauth costs
2025-06-25 14:27:19 +03:00