From e35d644acff7e23fbab6e451eb9d272fb862c1be Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sat, 17 May 2025 12:03:30 +0800 Subject: [PATCH] docs: update docs --- docs/cmd/hrp.md | 4 ++-- docs/cmd/hrp_adb.md | 2 +- docs/cmd/hrp_adb_devices.md | 2 +- docs/cmd/hrp_adb_install.md | 2 +- docs/cmd/hrp_adb_screencap.md | 2 +- docs/cmd/hrp_build.md | 2 +- docs/cmd/hrp_convert.md | 2 +- docs/cmd/hrp_ios.md | 2 +- docs/cmd/hrp_ios_apps.md | 2 +- docs/cmd/hrp_ios_devices.md | 2 +- docs/cmd/hrp_ios_install.md | 2 +- docs/cmd/hrp_ios_mount.md | 2 +- docs/cmd/hrp_ios_ps.md | 2 +- docs/cmd/hrp_ios_reboot.md | 2 +- docs/cmd/hrp_ios_tunnel.md | 2 +- docs/cmd/hrp_ios_uninstall.md | 2 +- docs/cmd/hrp_ios_xctest.md | 2 +- docs/cmd/hrp_mcphost.md | 14 +++++++------- docs/cmd/hrp_pytest.md | 2 +- docs/cmd/hrp_run.md | 2 +- docs/cmd/hrp_server.md | 2 +- docs/cmd/hrp_startproject.md | 2 +- docs/cmd/hrp_wiki.md | 2 +- internal/version/VERSION | 2 +- mcphost/chat.go | 21 ++++++++++----------- mcphost/chat_test.go | 2 +- mcphost/dump.go | 4 ++-- server/tool.go | 2 +- 28 files changed, 45 insertions(+), 46 deletions(-) diff --git a/docs/cmd/hrp.md b/docs/cmd/hrp.md index 3cddedd3..e9556db5 100644 --- a/docs/cmd/hrp.md +++ b/docs/cmd/hrp.md @@ -54,11 +54,11 @@ Copyright © 2017-present debugtalk. Apache-2.0 License. * [hrp build](hrp_build.md) - Build plugin for testing * [hrp convert](hrp_convert.md) - Convert multiple source format to HttpRunner JSON/YAML/gotest/pytest cases * [hrp ios](hrp_ios.md) - simple utils for ios device management -* [hrp mcphost](hrp_mcphost.md) - Export MCP server tools to JSON description +* [hrp mcphost](hrp_mcphost.md) - Start a chat session to interact with MCP tools * [hrp pytest](hrp_pytest.md) - Run API test with pytest * [hrp run](hrp_run.md) - Run API test with go engine * [hrp server](hrp_server.md) - Start hrp server * [hrp startproject](hrp_startproject.md) - Create a scaffold project * [hrp wiki](hrp_wiki.md) - visit https://httprunner.com -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_adb.md b/docs/cmd/hrp_adb.md index e4c0afca..03a82bb4 100644 --- a/docs/cmd/hrp_adb.md +++ b/docs/cmd/hrp_adb.md @@ -23,4 +23,4 @@ simple utils for android device management * [hrp adb install](hrp_adb_install.md) - push package to the device and install them automatically * [hrp adb screencap](hrp_adb_screencap.md) - Start android screen capture -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_adb_devices.md b/docs/cmd/hrp_adb_devices.md index e5f99a90..5c0560e8 100644 --- a/docs/cmd/hrp_adb_devices.md +++ b/docs/cmd/hrp_adb_devices.md @@ -24,4 +24,4 @@ hrp adb devices [flags] * [hrp adb](hrp_adb.md) - simple utils for android device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_adb_install.md b/docs/cmd/hrp_adb_install.md index c0e2f8aa..d78b7845 100644 --- a/docs/cmd/hrp_adb_install.md +++ b/docs/cmd/hrp_adb_install.md @@ -28,4 +28,4 @@ hrp adb install [flags] PACKAGE * [hrp adb](hrp_adb.md) - simple utils for android device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_adb_screencap.md b/docs/cmd/hrp_adb_screencap.md index 90e1ab9e..17a049c8 100644 --- a/docs/cmd/hrp_adb_screencap.md +++ b/docs/cmd/hrp_adb_screencap.md @@ -25,4 +25,4 @@ hrp adb screencap [flags] * [hrp adb](hrp_adb.md) - simple utils for android device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_build.md b/docs/cmd/hrp_build.md index 4e6feac7..1166f9a6 100644 --- a/docs/cmd/hrp_build.md +++ b/docs/cmd/hrp_build.md @@ -36,4 +36,4 @@ hrp build $path ... [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_convert.md b/docs/cmd/hrp_convert.md index e392d1de..acf30fe0 100644 --- a/docs/cmd/hrp_convert.md +++ b/docs/cmd/hrp_convert.md @@ -34,4 +34,4 @@ hrp convert $path... [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios.md b/docs/cmd/hrp_ios.md index 3c764260..b71379d1 100644 --- a/docs/cmd/hrp_ios.md +++ b/docs/cmd/hrp_ios.md @@ -29,4 +29,4 @@ simple utils for ios device management * [hrp ios uninstall](hrp_ios_uninstall.md) - uninstall package automatically * [hrp ios xctest](hrp_ios_xctest.md) - run xctest -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_apps.md b/docs/cmd/hrp_ios_apps.md index 5f36bdbf..fb930482 100644 --- a/docs/cmd/hrp_ios_apps.md +++ b/docs/cmd/hrp_ios_apps.md @@ -26,4 +26,4 @@ hrp ios apps [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_devices.md b/docs/cmd/hrp_ios_devices.md index 6a34580e..e17a72aa 100644 --- a/docs/cmd/hrp_ios_devices.md +++ b/docs/cmd/hrp_ios_devices.md @@ -24,4 +24,4 @@ hrp ios devices [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_install.md b/docs/cmd/hrp_ios_install.md index 2175c4df..2124374d 100644 --- a/docs/cmd/hrp_ios_install.md +++ b/docs/cmd/hrp_ios_install.md @@ -25,4 +25,4 @@ hrp ios install [flags] PACKAGE * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_mount.md b/docs/cmd/hrp_ios_mount.md index bc0d5fde..0d9e458f 100644 --- a/docs/cmd/hrp_ios_mount.md +++ b/docs/cmd/hrp_ios_mount.md @@ -28,4 +28,4 @@ hrp ios mount [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_ps.md b/docs/cmd/hrp_ios_ps.md index c6d7e422..121283da 100644 --- a/docs/cmd/hrp_ios_ps.md +++ b/docs/cmd/hrp_ios_ps.md @@ -26,4 +26,4 @@ hrp ios ps [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_reboot.md b/docs/cmd/hrp_ios_reboot.md index 13360607..1d52faf2 100644 --- a/docs/cmd/hrp_ios_reboot.md +++ b/docs/cmd/hrp_ios_reboot.md @@ -25,4 +25,4 @@ hrp ios reboot [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_tunnel.md b/docs/cmd/hrp_ios_tunnel.md index dac01ecc..e89adc89 100644 --- a/docs/cmd/hrp_ios_tunnel.md +++ b/docs/cmd/hrp_ios_tunnel.md @@ -24,4 +24,4 @@ hrp ios tunnel [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_uninstall.md b/docs/cmd/hrp_ios_uninstall.md index 1b342b45..0fc0e105 100644 --- a/docs/cmd/hrp_ios_uninstall.md +++ b/docs/cmd/hrp_ios_uninstall.md @@ -26,4 +26,4 @@ hrp ios uninstall [flags] PACKAGE * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_ios_xctest.md b/docs/cmd/hrp_ios_xctest.md index 6ccb8a53..6f9be1d1 100644 --- a/docs/cmd/hrp_ios_xctest.md +++ b/docs/cmd/hrp_ios_xctest.md @@ -28,4 +28,4 @@ hrp ios xctest [flags] * [hrp ios](hrp_ios.md) - simple utils for ios device management -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_mcphost.md b/docs/cmd/hrp_mcphost.md index be965015..8046a9b0 100644 --- a/docs/cmd/hrp_mcphost.md +++ b/docs/cmd/hrp_mcphost.md @@ -1,11 +1,10 @@ ## hrp mcphost -Export MCP server tools to JSON description +Start a chat session to interact with MCP tools ### Synopsis -Export all tools from MCP servers to JSON description. -The tools will be exported with their descriptions, parameters, and return values. +mcphost is a command-line tool that allows you to interact with MCP tools. ``` hrp mcphost [flags] @@ -14,9 +13,10 @@ hrp mcphost [flags] ### Options ``` - --dump string path to save the exported tools JSON file (default "tools_records.json") - -h, --help help for mcphost - -c, --mcp-config string path to the MCP config file (default "$HOME/.hrp/mcp.json") + --dump string path to save the exported tools JSON file + -h, --help help for mcphost + -c, --mcp-config string path to the MCP config file (default "$HOME/.hrp/mcp.json") + --system-prompt string path to system prompt JSON file ``` ### Options inherited from parent commands @@ -31,4 +31,4 @@ hrp mcphost [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_pytest.md b/docs/cmd/hrp_pytest.md index fd7867bb..bc5a66f9 100644 --- a/docs/cmd/hrp_pytest.md +++ b/docs/cmd/hrp_pytest.md @@ -24,4 +24,4 @@ hrp pytest $path ... [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_run.md b/docs/cmd/hrp_run.md index 3a37f034..84b58787 100644 --- a/docs/cmd/hrp_run.md +++ b/docs/cmd/hrp_run.md @@ -44,4 +44,4 @@ hrp run $path... [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_server.md b/docs/cmd/hrp_server.md index fc9c9f5e..a3591f4c 100644 --- a/docs/cmd/hrp_server.md +++ b/docs/cmd/hrp_server.md @@ -30,4 +30,4 @@ hrp server start [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_startproject.md b/docs/cmd/hrp_startproject.md index 13f75578..4c97d0f2 100644 --- a/docs/cmd/hrp_startproject.md +++ b/docs/cmd/hrp_startproject.md @@ -29,4 +29,4 @@ hrp startproject $project_name [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/docs/cmd/hrp_wiki.md b/docs/cmd/hrp_wiki.md index 8fb37fb8..cf95d13e 100644 --- a/docs/cmd/hrp_wiki.md +++ b/docs/cmd/hrp_wiki.md @@ -24,4 +24,4 @@ hrp wiki [flags] * [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance -###### Auto generated by spf13/cobra on 16-May-2025 +###### Auto generated by spf13/cobra on 17-May-2025 diff --git a/internal/version/VERSION b/internal/version/VERSION index e4c3c436..74c32855 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2505171155 +v5.0.0-beta-2505171220 diff --git a/mcphost/chat.go b/mcphost/chat.go index 67550d68..0568d8fa 100644 --- a/mcphost/chat.go +++ b/mcphost/chat.go @@ -36,15 +36,6 @@ func (h *MCPHost) NewChat(ctx context.Context, systemPromptFile string) (*Chat, return nil, errors.Wrap(code.LLMPrepareRequestError, err.Error()) } - // Create markdown renderer - renderer, err := glamour.NewTermRenderer( - glamour.WithStandardStyle(styles.TokyoNightStyle), - glamour.WithWordWrap(getTerminalWidth()), - ) - if err != nil { - return nil, errors.Wrap(err, "failed to create markdown renderer") - } - // Load system prompt from file if provided systemPrompt := "chat to interact with MCP tools" if systemPromptFile != "" { @@ -57,17 +48,25 @@ func (h *MCPHost) NewChat(ctx context.Context, systemPromptFile string) (*Chat, } } - // convert MCP tools to eino tool infos + // Convert MCP tools to eino tool infos einoTools, err := h.GetEinoToolInfos(ctx) if err != nil { return nil, errors.Wrap(err, "failed to get eino tool infos") } - toolCallingModel, err := model.WithTools(einoTools) if err != nil { return nil, errors.Wrap(code.LLMPrepareRequestError, err.Error()) } + // Create markdown renderer + renderer, err := glamour.NewTermRenderer( + glamour.WithStandardStyle(styles.TokyoNightStyle), + glamour.WithWordWrap(getTerminalWidth()), + ) + if err != nil { + return nil, errors.Wrap(err, "failed to create markdown renderer") + } + return &Chat{ model: toolCallingModel, systemPrompt: systemPrompt, diff --git a/mcphost/chat_test.go b/mcphost/chat_test.go index f45f4ce8..62a5944d 100644 --- a/mcphost/chat_test.go +++ b/mcphost/chat_test.go @@ -11,7 +11,7 @@ import ( func TestNewChat(t *testing.T) { systemPromptFile := "test_system_prompt.txt" - _ = os.WriteFile(systemPromptFile, []byte("You are a helpful assistant."), 0o644) + _ = os.WriteFile(systemPromptFile, []byte("You are a helpful assistant."), 0o600) defer os.Remove(systemPromptFile) host, err := NewMCPHost("./testdata/test.mcp.json") diff --git a/mcphost/dump.go b/mcphost/dump.go index 98316850..bcb29291 100644 --- a/mcphost/dump.go +++ b/mcphost/dump.go @@ -122,7 +122,7 @@ func ConvertToolsToRecords(tools []MCPTools) []MCPToolRecord { for _, tool := range mcpTools.Tools { // Generate unique ID by combining server name and tool name - id := fmt.Sprintf("%s_%s", mcpTools.ServerName, tool.Name) + id := fmt.Sprintf("%s__%s", mcpTools.ServerName, tool.Name) // Extract docstring information info := extractDocStringInfo(tool.Description) @@ -172,7 +172,7 @@ func (h *MCPHost) ExportToolsToJSON(ctx context.Context, dumpPath string) error // create output directory outputDir := filepath.Dir(dumpPath) if outputDir != "." { - if err := os.MkdirAll(outputDir, 0o755); err != nil { + if err := os.MkdirAll(outputDir, 0o754); err != nil { return fmt.Errorf("failed to create output directory: %w", err) } } diff --git a/server/tool.go b/server/tool.go index fe71e3c9..42191ab0 100644 --- a/server/tool.go +++ b/server/tool.go @@ -14,7 +14,7 @@ type ToolRequest struct { func (r *Router) invokeToolHandler(c *gin.Context) { if r.mcpHost == nil { - RenderError(c, errors.New("mcp host not initialized")) + RenderError(c, errors.New("mcphost not initialized")) return }