docs: add comprehensive documentation for MCP server

- Add detailed package-level documentation for mcp_server.go
- Create MCP_SERVER_DOCUMENTATION.md with complete implementation guide
- Create MCP_TOOLS_REFERENCE.md with quick reference for all tools
- Add extensive code comments for key structures and functions
- Document architecture, features, extension guide, and best practices
- Include usage examples and troubleshooting information

This provides complete documentation for developers to understand,
use, and extend the HttpRunner MCP server functionality.
This commit is contained in:
lilong.129
2025-05-30 00:37:26 +08:00
parent 4e77ec4002
commit f702a3cc78
4 changed files with 1166 additions and 33 deletions
+34
View File
@@ -11,6 +11,7 @@ import (
func TestNewMCPServer(t *testing.T) {
server := NewMCPServer()
assert.NotNil(t, server)
assert.NotEmpty(t, server.ListTools())
// Check that tools are registered
tools := server.ListTools()
@@ -1528,3 +1529,36 @@ func TestToolWebCloseTab(t *testing.T) {
_, err = tool.ConvertActionToCallToolRequest(invalidAction)
assert.Error(t, err)
}
func TestPreMarkOperationConfiguration(t *testing.T) {
// Test that pre_mark_operation is configurable and not hardcoded
server := NewMCPServer()
// Get the tap_xy tool
tapTool := server.GetToolByAction(option.ACTION_TapXY)
assert.NotNil(t, tapTool)
// Test conversion with pre_mark_operation enabled
actionWithPreMark := MobileAction{
Method: option.ACTION_TapXY,
Params: []float64{0.5, 0.5},
ActionOptions: *option.NewActionOptions(option.WithPreMarkOperation(true)),
}
request, err := tapTool.ConvertActionToCallToolRequest(actionWithPreMark)
assert.NoError(t, err)
assert.Equal(t, true, request.Params.Arguments["pre_mark_operation"])
// Test conversion without pre_mark_operation
actionWithoutPreMark := MobileAction{
Method: option.ACTION_TapXY,
Params: []float64{0.5, 0.5},
ActionOptions: *option.NewActionOptions(option.WithPreMarkOperation(false)),
}
request2, err := tapTool.ConvertActionToCallToolRequest(actionWithoutPreMark)
assert.NoError(t, err)
// Should not have pre_mark_operation in arguments when false
_, exists := request2.Params.Arguments["pre_mark_operation"]
assert.False(t, exists)
}