Commit 6dde388
authored
Add Model Context Protocol (MCP) server support (#4)
* Add MCP dependency for Model Context Protocol support
- Add github.com/mark3labs/mcp-go v0.32.0 dependency
- Prepare foundation for MCP server implementation
- Part of Phase 1.1 of MCP implementation plan
* Add MCP mode detection and configuration
- Add --mcp CLI flag for MCP server mode
- Support SPOTINFO_MODE, MCP_TRANSPORT, MCP_PORT environment variables
- Implement mode detection with proper fallbacks
- Use modern Go 1.24 patterns (os.LookupEnv)
- Add context cancellation support for MCP server
- Part of Phase 1.2 of MCP implementation plan
* Implement basic MCP server infrastructure
- Create internal/mcp package with server setup
- Add MCP server with tool capabilities and logging
- Integrate MCP server with main application lifecycle
- Support stdio transport (SSE transport placeholder for Phase 3.2)
- Add mark3labs/mcp-go to depguard allowed imports
- Fix struct field alignment and remove unused return values
- Part of Phase 1.3 of MCP implementation plan
Ready for Phase 2: tool implementation
* Implement Phase 2.1: MCP tools with comprehensive testing
* Add find_spot_instances tool with parameter validation and filtering
* Add list_spot_regions tool for dynamic region discovery
* Implement safe parameter parsing with spf13/cast
* Create comprehensive table-driven tests with 100% coverage
* Add mockery v3 integration for interface mocking
* Extract magic numbers to named constants for maintainability
* Follow Go best practices: private interfaces, safe type assertions
* Reduce cyclomatic complexity with helper function extraction
* Add proper error handling with MCP-compliant responses
Phase 2.1 complete: Core MCP tool functionality implemented
* Add comprehensive MCP documentation and minor tool improvements
* Add extensive README.md MCP section with setup guides and examples
* Create detailed Claude Desktop integration guide (docs/claude-desktop-setup.md)
* Add comprehensive troubleshooting documentation (docs/troubleshooting.md)
* Create complete API reference with JSON schemas (docs/api-reference.md)
* Add inline documentation comments to tools.go struct fields
* Provide platform-specific configuration examples and debug procedures
Documentation enables easy MCP server integration and troubleshooting
* Optimize and simplify Makefile
- Remove complex variables and over-engineering
- Eliminate fmt dependency from test targets
- Streamline cross-platform release build process
- Remove unused targets and improve readability
- Reduce from 157 to 129 lines while maintaining functionality
* Add comprehensive MCP server testing and implement SSE transport
- Add extensive test coverage for MCP mode detection and configuration
- Implement SSE transport using mcp-go library built-in support
- Add transport-specific test suites for stdio and SSE
- Test MCP CLI integration scenarios and error handling
* Fix golangci-lint installation to use v2 module path
* Enhance test coverage with comprehensive MCP handler tests
- Add comprehensive tests for FindSpotInstancesTool.Handle with 7 scenarios
- Add tests for ListSpotRegionsTool.Handle with 4 scenarios including deduplication
- Add error handling tests for createErrorResult function
- Improve test structure with proper JSON validation and response checking
- Fix test assertions to properly validate MCP error results vs success results
- Increase MCP package coverage from 68.6% to 98.3%
- Increase overall project coverage from 77.7% to 85.6%
* Enhance testing with race detection, benchmarks, and linter fixes
- Fix forcetypeassert linter errors with proper type assertion checks
- Add comprehensive race condition tests for concurrent client access
- Add performance benchmarks for critical code paths and memory analysis
- Suppress maintidx warning for complex table-driven test
- Improve test coverage from 77.7% to 86.0%1 parent 2549584 commit 6dde388
File tree
20 files changed
+5736
-131
lines changed- cmd/spotinfo
- docs
- internal/mcp
20 files changed
+5736
-131
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | | - | |
4 | | - | |
5 | 7 | | |
6 | 8 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 9 | | |
18 | | - | |
19 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
26 | 23 | | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 27 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 28 | + | |
| 29 | + | |
64 | 30 | | |
65 | | - | |
| 31 | + | |
| 32 | + | |
66 | 33 | | |
67 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
68 | 38 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
73 | 43 | | |
74 | | - | |
75 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
76 | 47 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
81 | 51 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
89 | 66 | | |
90 | | - | |
91 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
92 | 74 | | |
93 | | - | |
94 | | - | |
| 75 | + | |
95 | 76 | | |
96 | | - | |
97 | | - | |
| 77 | + | |
| 78 | + | |
98 | 79 | | |
99 | | - | |
| 80 | + | |
100 | 81 | | |
101 | 82 | | |
102 | 83 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
148 | 103 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
153 | 109 | | |
154 | | - | |
| 110 | + | |
155 | 111 | | |
156 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
0 commit comments