simplecov-mcp 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +173 -356
- data/docs/ADVANCED_USAGE.md +967 -0
- data/docs/ARCHITECTURE.md +79 -0
- data/docs/BRANCH_ONLY_COVERAGE.md +81 -0
- data/docs/CLI_USAGE.md +637 -0
- data/docs/DEVELOPMENT.md +82 -0
- data/docs/ERROR_HANDLING.md +93 -0
- data/docs/EXAMPLES.md +430 -0
- data/docs/INSTALLATION.md +352 -0
- data/docs/LIBRARY_API.md +635 -0
- data/docs/MCP_INTEGRATION.md +488 -0
- data/docs/TROUBLESHOOTING.md +276 -0
- data/docs/arch-decisions/001-x-arch-decision.md +93 -0
- data/docs/arch-decisions/002-x-arch-decision.md +157 -0
- data/docs/arch-decisions/003-x-arch-decision.md +163 -0
- data/docs/arch-decisions/004-x-arch-decision.md +199 -0
- data/docs/arch-decisions/005-x-arch-decision.md +187 -0
- data/docs/arch-decisions/README.md +60 -0
- data/docs/presentations/simplecov-mcp-presentation.md +249 -0
- data/exe/simplecov-mcp +4 -4
- data/lib/simplecov_mcp/app_context.rb +26 -0
- data/lib/simplecov_mcp/base_tool.rb +74 -0
- data/lib/simplecov_mcp/cli.rb +234 -0
- data/lib/simplecov_mcp/cli_config.rb +56 -0
- data/lib/simplecov_mcp/commands/base_command.rb +78 -0
- data/lib/simplecov_mcp/commands/command_factory.rb +39 -0
- data/lib/simplecov_mcp/commands/detailed_command.rb +24 -0
- data/lib/simplecov_mcp/commands/list_command.rb +13 -0
- data/lib/simplecov_mcp/commands/raw_command.rb +22 -0
- data/lib/simplecov_mcp/commands/summary_command.rb +24 -0
- data/lib/simplecov_mcp/commands/uncovered_command.rb +26 -0
- data/lib/simplecov_mcp/commands/version_command.rb +18 -0
- data/lib/simplecov_mcp/constants.rb +22 -0
- data/lib/simplecov_mcp/error_handler.rb +124 -0
- data/lib/simplecov_mcp/error_handler_factory.rb +31 -0
- data/lib/simplecov_mcp/errors.rb +179 -0
- data/lib/simplecov_mcp/formatters/source_formatter.rb +148 -0
- data/lib/simplecov_mcp/mcp_server.rb +40 -0
- data/lib/simplecov_mcp/mode_detector.rb +55 -0
- data/lib/simplecov_mcp/model.rb +300 -0
- data/lib/simplecov_mcp/option_normalizers.rb +92 -0
- data/lib/simplecov_mcp/option_parser_builder.rb +134 -0
- data/lib/simplecov_mcp/option_parsers/env_options_parser.rb +50 -0
- data/lib/simplecov_mcp/option_parsers/error_helper.rb +109 -0
- data/lib/simplecov_mcp/path_relativizer.rb +61 -0
- data/lib/simplecov_mcp/presenters/base_coverage_presenter.rb +44 -0
- data/lib/simplecov_mcp/presenters/coverage_detailed_presenter.rb +16 -0
- data/lib/simplecov_mcp/presenters/coverage_raw_presenter.rb +16 -0
- data/lib/simplecov_mcp/presenters/coverage_summary_presenter.rb +16 -0
- data/lib/simplecov_mcp/presenters/coverage_uncovered_presenter.rb +16 -0
- data/lib/simplecov_mcp/presenters/project_coverage_presenter.rb +52 -0
- data/lib/simplecov_mcp/resolvers/coverage_line_resolver.rb +126 -0
- data/lib/simplecov_mcp/resolvers/resolver_factory.rb +28 -0
- data/lib/simplecov_mcp/resolvers/resultset_path_resolver.rb +78 -0
- data/lib/simplecov_mcp/resultset_loader.rb +136 -0
- data/lib/simplecov_mcp/staleness_checker.rb +243 -0
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/all_files_coverage_tool.rb +31 -13
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/coverage_detailed_tool.rb +7 -7
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/coverage_raw_tool.rb +7 -7
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/coverage_summary_tool.rb +7 -7
- data/lib/simplecov_mcp/tools/coverage_table_tool.rb +90 -0
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/help_tool.rb +13 -4
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/uncovered_lines_tool.rb +7 -7
- data/lib/{simple_cov_mcp → simplecov_mcp}/tools/version_tool.rb +11 -3
- data/lib/simplecov_mcp/util.rb +82 -0
- data/lib/{simple_cov_mcp → simplecov_mcp}/version.rb +1 -1
- data/lib/simplecov_mcp.rb +144 -2
- data/spec/MCP_INTEGRATION_TESTS_README.md +111 -0
- data/spec/TIMESTAMPS.md +48 -0
- data/spec/all_files_coverage_tool_spec.rb +29 -25
- data/spec/base_tool_spec.rb +11 -10
- data/spec/cli/show_default_report_spec.rb +33 -0
- data/spec/cli_config_spec.rb +137 -0
- data/spec/cli_enumerated_options_spec.rb +68 -0
- data/spec/cli_error_spec.rb +105 -47
- data/spec/cli_source_spec.rb +82 -23
- data/spec/cli_spec.rb +140 -5
- data/spec/cli_success_predicate_spec.rb +141 -0
- data/spec/cli_table_spec.rb +1 -1
- data/spec/cli_usage_spec.rb +10 -26
- data/spec/commands/base_command_spec.rb +187 -0
- data/spec/commands/command_factory_spec.rb +72 -0
- data/spec/commands/detailed_command_spec.rb +48 -0
- data/spec/commands/raw_command_spec.rb +46 -0
- data/spec/commands/summary_command_spec.rb +47 -0
- data/spec/commands/uncovered_command_spec.rb +49 -0
- data/spec/constants_spec.rb +61 -0
- data/spec/coverage_table_tool_spec.rb +17 -33
- data/spec/error_handler_spec.rb +22 -13
- data/spec/error_mode_spec.rb +143 -0
- data/spec/errors_edge_cases_spec.rb +239 -0
- data/spec/errors_stale_spec.rb +2 -2
- data/spec/file_based_mcp_tools_spec.rb +99 -0
- data/spec/fixtures/project1/lib/bar.rb +0 -1
- data/spec/fixtures/project1/lib/foo.rb +0 -1
- data/spec/help_tool_spec.rb +11 -17
- data/spec/integration_spec.rb +845 -0
- data/spec/logging_fallback_spec.rb +128 -0
- data/spec/mcp_logging_spec.rb +44 -0
- data/spec/mcp_server_integration_spec.rb +23 -0
- data/spec/mcp_server_spec.rb +15 -4
- data/spec/mode_detector_spec.rb +148 -0
- data/spec/model_error_handling_spec.rb +210 -0
- data/spec/model_staleness_spec.rb +40 -10
- data/spec/option_normalizers_spec.rb +204 -0
- data/spec/option_parsers/env_options_parser_spec.rb +233 -0
- data/spec/option_parsers/error_helper_spec.rb +222 -0
- data/spec/path_relativizer_spec.rb +83 -0
- data/spec/presenters/coverage_detailed_presenter_spec.rb +19 -0
- data/spec/presenters/coverage_raw_presenter_spec.rb +15 -0
- data/spec/presenters/coverage_summary_presenter_spec.rb +15 -0
- data/spec/presenters/coverage_uncovered_presenter_spec.rb +16 -0
- data/spec/presenters/project_coverage_presenter_spec.rb +86 -0
- data/spec/resolvers/coverage_line_resolver_spec.rb +57 -0
- data/spec/resolvers/resolver_factory_spec.rb +61 -0
- data/spec/resolvers/resultset_path_resolver_spec.rb +55 -0
- data/spec/resultset_loader_spec.rb +167 -0
- data/spec/shared_examples/README.md +115 -0
- data/spec/shared_examples/coverage_presenter_examples.rb +66 -0
- data/spec/shared_examples/file_based_mcp_tools.rb +174 -0
- data/spec/shared_examples/mcp_tool_text_json_response.rb +16 -0
- data/spec/simple_cov_mcp_module_spec.rb +16 -0
- data/spec/simplecov_mcp_model_spec.rb +340 -9
- data/spec/simplecov_mcp_opts_spec.rb +182 -0
- data/spec/spec_helper.rb +147 -4
- data/spec/staleness_checker_spec.rb +373 -0
- data/spec/staleness_more_spec.rb +16 -13
- data/spec/support/mcp_runner.rb +64 -0
- data/spec/tools_error_handling_spec.rb +144 -0
- data/spec/util_spec.rb +109 -34
- data/spec/version_spec.rb +117 -9
- data/spec/version_tool_spec.rb +131 -10
- metadata +120 -63
- data/lib/simple_cov/mcp.rb +0 -9
- data/lib/simple_cov_mcp/base_tool.rb +0 -70
- data/lib/simple_cov_mcp/cli.rb +0 -390
- data/lib/simple_cov_mcp/error_handler.rb +0 -131
- data/lib/simple_cov_mcp/error_handler_factory.rb +0 -38
- data/lib/simple_cov_mcp/errors.rb +0 -176
- data/lib/simple_cov_mcp/mcp_server.rb +0 -30
- data/lib/simple_cov_mcp/model.rb +0 -104
- data/lib/simple_cov_mcp/staleness_checker.rb +0 -125
- data/lib/simple_cov_mcp/tools/coverage_table_tool.rb +0 -61
- data/lib/simple_cov_mcp/util.rb +0 -122
- data/lib/simple_cov_mcp.rb +0 -102
- data/spec/coverage_detailed_tool_spec.rb +0 -36
- data/spec/coverage_raw_tool_spec.rb +0 -32
- data/spec/coverage_summary_tool_spec.rb +0 -39
- data/spec/legacy_shim_spec.rb +0 -13
- data/spec/uncovered_lines_tool_spec.rb +0 -33
@@ -0,0 +1,488 @@
|
|
1
|
+
# MCP Integration Guide
|
2
|
+
|
3
|
+
This guide covers setting up simplecov-mcp as an MCP (Model Context Protocol) server for AI coding assistants.
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [What is MCP?](#what-is-mcp)
|
8
|
+
- [Prerequisites](#prerequisites)
|
9
|
+
- [Quick Start](#quick-start)
|
10
|
+
- [Setup by Client](#setup-by-client)
|
11
|
+
- [Available MCP Tools](#available-mcp-tools)
|
12
|
+
- [Testing Your Setup](#testing-your-setup)
|
13
|
+
- [Troubleshooting](#troubleshooting)
|
14
|
+
|
15
|
+
## What is MCP?
|
16
|
+
|
17
|
+
The Model Context Protocol (MCP) is a standard for integrating tools and data sources with AI assistants. By running simplecov-mcp as an MCP server, you enable AI coding assistants to:
|
18
|
+
|
19
|
+
- Query coverage data for files
|
20
|
+
- Identify uncovered code
|
21
|
+
- Analyze coverage gaps
|
22
|
+
- Suggest improvements based on coverage data
|
23
|
+
|
24
|
+
### Why Use MCP with Coverage Tools?
|
25
|
+
|
26
|
+
AI assistants can help you:
|
27
|
+
- **Prioritize testing** - "Which files need coverage most urgently?"
|
28
|
+
- **Understand gaps** - "Why is this file's coverage low?"
|
29
|
+
- **Generate tests** - "Write tests for uncovered lines in this file"
|
30
|
+
- **Track progress** - "Has coverage improved since last commit?"
|
31
|
+
|
32
|
+
## Prerequisites
|
33
|
+
|
34
|
+
- **Ruby >= 3.2** (required by MCP gem dependency)
|
35
|
+
- **simplecov-mcp installed** - See [Installation Guide](INSTALLATION.md)
|
36
|
+
- **simplecov gem >= 0.21** - Needed when a resultset contains multiple suites (loaded lazily)
|
37
|
+
- **Coverage data** - Run tests to generate `coverage/.resultset.json`
|
38
|
+
- **MCP-compatible client** - Claude Code, Cursor, Codex, etc.
|
39
|
+
|
40
|
+
## Quick Start
|
41
|
+
|
42
|
+
### 1. Install simplecov-mcp
|
43
|
+
|
44
|
+
```sh
|
45
|
+
gem install simplecov-mcp
|
46
|
+
```
|
47
|
+
|
48
|
+
### 2. Verify Installation
|
49
|
+
|
50
|
+
```sh
|
51
|
+
# Find the executable path (needed for MCP configuration)
|
52
|
+
which simplecov-mcp
|
53
|
+
|
54
|
+
# Test it works
|
55
|
+
simplecov-mcp version
|
56
|
+
```
|
57
|
+
|
58
|
+
### 3. Configure Your AI Assistant
|
59
|
+
|
60
|
+
See [Setup by Client](#setup-by-client) below for specific instructions.
|
61
|
+
|
62
|
+
### 4. Generate Coverage Data
|
63
|
+
|
64
|
+
```sh
|
65
|
+
# Run your test suite
|
66
|
+
bundle exec rspec # or your test command
|
67
|
+
|
68
|
+
# Verify coverage file exists
|
69
|
+
ls coverage/.resultset.json
|
70
|
+
```
|
71
|
+
|
72
|
+
> **Multi-suite note:** If the resultset contains several suites (e.g., `RSpec` and `Cucumber`), simplecov-mcp lazily loads the `simplecov` gem and merges them before answering coverage queries. Staleness checks currently use the newest suite’s timestamp, so treat multi-suite freshness warnings as advisory until per-file timestamps are introduced.
|
73
|
+
>
|
74
|
+
> Only suites stored in a *single* `.resultset.json` are merged automatically. If your test runs produce multiple resultset files, merge them (e.g., via `SimpleCov::ResultMerger.merge_and_store`) and point simplecov-mcp at the combined file.
|
75
|
+
|
76
|
+
> Multifile support may be added in a future version (post an issue if you want this).
|
77
|
+
|
78
|
+
### 5. Test the MCP Server
|
79
|
+
|
80
|
+
```sh
|
81
|
+
# Test manually
|
82
|
+
echo '''{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"version_tool","arguments":{}}}''' | simplecov-mcp
|
83
|
+
```
|
84
|
+
|
85
|
+
You should see a JSON-RPC response with version information.
|
86
|
+
|
87
|
+
## Setup by Client
|
88
|
+
|
89
|
+
### Claude Code
|
90
|
+
|
91
|
+
**Current Status:** Claude Code has a bug in its MCP client that prevents it from working with spec-compliant MCP servers like simplecov-mcp. Claude Code will automatically fall back to using the CLI interface.
|
92
|
+
|
93
|
+
**Bug Report:** [Claude Code Issue #8239](https://github.com/anthropics/claude-code/issues/8239)
|
94
|
+
|
95
|
+
**Workaround:** Use the CLI interface, which provides the same functionality:
|
96
|
+
```sh
|
97
|
+
# Instead of MCP tools, use CLI
|
98
|
+
simplecov-mcp list
|
99
|
+
simplecov-mcp summary lib/simplecov_mcp/cli.rb
|
100
|
+
```
|
101
|
+
|
102
|
+
**Configuration (for when bug is fixed):**
|
103
|
+
|
104
|
+
Using the Claude CLI tool:
|
105
|
+
|
106
|
+
```sh
|
107
|
+
# Basic setup (if simplecov-mcp is in default PATH)
|
108
|
+
claude mcp add simplecov-mcp simplecov-mcp
|
109
|
+
|
110
|
+
# With rbenv/asdf (use absolute path)
|
111
|
+
claude mcp add simplecov-mcp /Users/yourname/.rbenv/shims/simplecov-mcp
|
112
|
+
|
113
|
+
# With RVM wrapper (recommended for stability)
|
114
|
+
rvm wrapper ruby-3.3.8 simplecov-mcp simplecov-mcp
|
115
|
+
claude mcp add simplecov-mcp /Users/yourname/.rvm/wrappers/ruby-3.3.8/simplecov-mcp
|
116
|
+
|
117
|
+
# For user-wide configuration (default is local)
|
118
|
+
claude mcp add --scope user simplecov-mcp simplecov-mcp
|
119
|
+
|
120
|
+
# For project-specific configuration
|
121
|
+
claude mcp add --scope project simplecov-mcp simplecov-mcp
|
122
|
+
```
|
123
|
+
|
124
|
+
**Verify configuration:**
|
125
|
+
```sh
|
126
|
+
# List configured MCP servers
|
127
|
+
claude mcp list
|
128
|
+
|
129
|
+
# Get server details
|
130
|
+
claude mcp get simplecov-mcp
|
131
|
+
|
132
|
+
# Remove if needed
|
133
|
+
claude mcp remove simplecov-mcp
|
134
|
+
```
|
135
|
+
|
136
|
+
**Important Notes:**
|
137
|
+
- Default scope is `local` (current project)
|
138
|
+
- Use `--scope user` for global config, `--scope project` for project-specific
|
139
|
+
- The executable path is tied to Ruby version with version managers
|
140
|
+
- If you change Ruby versions, remove and re-add the configuration
|
141
|
+
|
142
|
+
### Cursor / Codex
|
143
|
+
|
144
|
+
Using the Codex CLI:
|
145
|
+
|
146
|
+
```sh
|
147
|
+
# Basic setup (if simplecov-mcp is in default PATH)
|
148
|
+
codex mcp add simplecov-mcp --command simplecov-mcp
|
149
|
+
|
150
|
+
# With rbenv/asdf (use absolute path)
|
151
|
+
codex mcp add simplecov-mcp --command /Users/yourname/.rbenv/shims/simplecov-mcp
|
152
|
+
|
153
|
+
# With RVM wrapper (recommended for stability)
|
154
|
+
rvm wrapper ruby-3.3.8 simplecov-mcp simplecov-mcp
|
155
|
+
codex mcp add simplecov-mcp --command /Users/yourname/.rvm/wrappers/ruby-3.3.8/simplecov-mcp
|
156
|
+
|
157
|
+
# List configured servers
|
158
|
+
codex mcp list
|
159
|
+
|
160
|
+
# Show server details
|
161
|
+
codex mcp get simplecov-mcp
|
162
|
+
|
163
|
+
# Remove if needed
|
164
|
+
codex mcp remove simplecov-mcp
|
165
|
+
```
|
166
|
+
|
167
|
+
**Find your executable path:**
|
168
|
+
```sh
|
169
|
+
which simplecov-mcp
|
170
|
+
```
|
171
|
+
|
172
|
+
### Gemini
|
173
|
+
|
174
|
+
Using the Gemini CLI:
|
175
|
+
|
176
|
+
```sh
|
177
|
+
# Add MCP server
|
178
|
+
gemini mcp add simplecov-mcp /Users/yourname/.rbenv/shims/simplecov-mcp
|
179
|
+
|
180
|
+
# Or with RVM
|
181
|
+
gemini mcp add simplecov-mcp /Users/yourname/.rvm/wrappers/ruby-3.3.8/simplecov-mcp
|
182
|
+
|
183
|
+
# List configured servers
|
184
|
+
gemini mcp list
|
185
|
+
|
186
|
+
# Remove if needed
|
187
|
+
gemini mcp remove simplecov-mcp
|
188
|
+
```
|
189
|
+
|
190
|
+
### Generic MCP Client
|
191
|
+
|
192
|
+
For any MCP client that uses JSON configuration:
|
193
|
+
|
194
|
+
```json
|
195
|
+
{
|
196
|
+
"mcpServers": {
|
197
|
+
"simplecov-mcp": {
|
198
|
+
"command": "/path/to/simplecov-mcp",
|
199
|
+
"args": [],
|
200
|
+
"env": {
|
201
|
+
"SIMPLECOV_MCP_OPTS": "--resultset coverage"
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
```
|
207
|
+
|
208
|
+
**Environment variables you can set:**
|
209
|
+
|
210
|
+
- `SIMPLECOV_MCP_OPTS` - Default CLI options (though less useful for MCP mode)
|
211
|
+
|
212
|
+
## Available MCP Tools
|
213
|
+
|
214
|
+
### Tool Catalog
|
215
|
+
|
216
|
+
simplecov-mcp exposes 8 MCP tools:
|
217
|
+
|
218
|
+
| Tool | Purpose | Key Parameters |
|
219
|
+
|------|---------|----------------|
|
220
|
+
| `coverage_summary_tool` | File coverage summary | `path` |
|
221
|
+
| `coverage_detailed_tool` | Per-line coverage | `path` |
|
222
|
+
| `coverage_raw_tool` | Raw SimpleCov array | `path` |
|
223
|
+
| `uncovered_lines_tool` | List uncovered lines | `path` |
|
224
|
+
| `all_files_coverage_tool` | Project-wide coverage | `sort_order`, `tracked_globs` |
|
225
|
+
| `coverage_table_tool` | Formatted coverage table | `sort_order` |
|
226
|
+
| `help_tool` | Tool discovery | `query` (optional) |
|
227
|
+
| `version_tool` | Version information | (none) |
|
228
|
+
|
229
|
+
### JSON Response Format
|
230
|
+
|
231
|
+
For tools that return structured data, `simplecov-mcp` serializes the data as a JSON string and returns it inside a `text` part of the MCP response.
|
232
|
+
|
233
|
+
**Example:**
|
234
|
+
```json
|
235
|
+
{
|
236
|
+
"type": "text",
|
237
|
+
"text": "{"coverage_summary":{"covered":10,"total":20,"pct":50.0}}"
|
238
|
+
}
|
239
|
+
```
|
240
|
+
|
241
|
+
**Reasoning:**
|
242
|
+
While returning JSON in a `resource` part with `mimeType: "application/json"` is more semantically correct, major MCP clients (including Google's Gemini and Anthropic's Claude) were found to not support this format, causing validation errors. They expect a `resource` part to contain a `uri`.
|
243
|
+
|
244
|
+
To ensure maximum compatibility, the decision was made to use a simple `text` part. This is a pragmatic compromise that has proven to be reliable across different clients.
|
245
|
+
|
246
|
+
**Further Reading:**
|
247
|
+
This decision was informed by discussions with multiple AI models. For more details, see these conversations:
|
248
|
+
- [Perplexity AI Discussion](https://www.perplexity.ai/search/title-resolving-a-model-contex-IfpFWU1FR5WQXQ8HcQctyg#0)
|
249
|
+
- [ChatGPT Discussion](https://chatgpt.com/share/68e4d7e1-cad4-800f-80c2-58b33bfc31cb)
|
250
|
+
|
251
|
+
### Common Parameters
|
252
|
+
|
253
|
+
All file-specific tools accept these parameters:
|
254
|
+
|
255
|
+
- `path` (required for file tools) - File path (relative or absolute)
|
256
|
+
- `root` (optional) - Project root directory (default: `.`)
|
257
|
+
- `resultset` (optional) - Path to the `.resultset.json` file. See [Configuring the Resultset](../README.md#configuring-the-resultset) for details.
|
258
|
+
- `stale` (optional) - Staleness mode: `"off"` (default) or `"error"`
|
259
|
+
- `error_mode` (optional) - Error handling: `"off"`, `"on"` (default), `"trace"`
|
260
|
+
|
261
|
+
### Tool Details
|
262
|
+
|
263
|
+
#### Per-File Tools
|
264
|
+
|
265
|
+
These tools analyze individual files. All require `path` parameter.
|
266
|
+
|
267
|
+
**`coverage_summary_tool`** - Covered/total/percentage summary
|
268
|
+
```json
|
269
|
+
{"file": "...", "summary": {"covered": 12, "total": 14, "pct": 85.71}, "stale": false}
|
270
|
+
```
|
271
|
+
|
272
|
+
**`uncovered_lines_tool`** - List uncovered line numbers
|
273
|
+
```json
|
274
|
+
{"file": "...", "uncovered": [5, 9, 12], "summary": {...}, "stale": false}
|
275
|
+
```
|
276
|
+
|
277
|
+
**`coverage_detailed_tool`** - Per-line hit counts
|
278
|
+
```json
|
279
|
+
{"file": "...", "lines": [{"line": 1, "hits": 1, "covered": true}, ...], "summary": {...}, "stale": false}
|
280
|
+
```
|
281
|
+
|
282
|
+
**`coverage_raw_tool`** - Raw SimpleCov lines array
|
283
|
+
```json
|
284
|
+
{"file": "...", "lines": [1, 0, null, 5, 2, null, 1], "stale": false}
|
285
|
+
```
|
286
|
+
|
287
|
+
#### Project-Wide Tools
|
288
|
+
|
289
|
+
**`all_files_coverage_tool`** - Coverage for all files
|
290
|
+
- Parameters: `sort_order` (`ascending`|`descending`), `tracked_globs` (array)
|
291
|
+
- Returns: `{"files": [...], "counts": {"total": N, "ok": N, "stale": N}}`
|
292
|
+
|
293
|
+
**`coverage_table_tool`** - Formatted ASCII table
|
294
|
+
- Parameters: `sort_order` (`ascending`|`descending`)
|
295
|
+
- Returns: Plain text table
|
296
|
+
|
297
|
+
#### Utility Tools
|
298
|
+
|
299
|
+
**`help_tool`** - Tool discovery (optional `query` parameter)
|
300
|
+
**`version_tool`** - Version information
|
301
|
+
|
302
|
+
## Example Prompts for AI Assistants
|
303
|
+
|
304
|
+
### Coverage Analysis
|
305
|
+
|
306
|
+
```
|
307
|
+
Using simplecov-mcp, show me a table of all files and their coverage percentages.
|
308
|
+
```
|
309
|
+
|
310
|
+
```
|
311
|
+
Using simplecov-mcp, find files with less than 80% coverage and tell me which ones to prioritize.
|
312
|
+
```
|
313
|
+
|
314
|
+
```
|
315
|
+
Using simplecov-mcp, analyze the coverage for lib/simplecov_mcp/tools/ and suggest improvements.
|
316
|
+
```
|
317
|
+
|
318
|
+
### Finding Coverage Gaps
|
319
|
+
|
320
|
+
```
|
321
|
+
Using simplecov-mcp, show me the uncovered lines in lib/simplecov_mcp/base_tool.rb and explain what they do.
|
322
|
+
```
|
323
|
+
|
324
|
+
```
|
325
|
+
Using simplecov-mcp, find the most important uncovered code in lib/simplecov_mcp/tools/coverage_detailed_tool.rb.
|
326
|
+
```
|
327
|
+
|
328
|
+
### Test Generation
|
329
|
+
|
330
|
+
```
|
331
|
+
Using simplecov-mcp, find uncovered lines in lib/simplecov_mcp/staleness_checker.rb and write RSpec tests for them.
|
332
|
+
```
|
333
|
+
|
334
|
+
```
|
335
|
+
Using simplecov-mcp, analyze coverage gaps in lib/simplecov_mcp/tools/ and generate test cases.
|
336
|
+
```
|
337
|
+
|
338
|
+
### Coverage Reporting
|
339
|
+
|
340
|
+
```
|
341
|
+
Using simplecov-mcp, create a markdown report of:
|
342
|
+
- Files with worst coverage
|
343
|
+
- Most critical coverage gaps
|
344
|
+
- Recommended action items
|
345
|
+
```
|
346
|
+
|
347
|
+
## Testing Your Setup
|
348
|
+
|
349
|
+
### Manual Testing via Command Line
|
350
|
+
|
351
|
+
Test the MCP server responds to JSON-RPC:
|
352
|
+
|
353
|
+
```sh
|
354
|
+
# Test version tool (simplest)
|
355
|
+
echo '''{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"version_tool","arguments":{}}}''' | simplecov-mcp
|
356
|
+
|
357
|
+
# Test summary tool
|
358
|
+
echo '''{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"coverage_summary_tool","arguments":{"path":"lib/simplecov_mcp/model.rb"}}}''' | simplecov-mcp
|
359
|
+
|
360
|
+
# Test help tool
|
361
|
+
echo '''{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"help_tool","arguments":{}}}''' | simplecov-mcp
|
362
|
+
```
|
363
|
+
|
364
|
+
**Important:** JSON-RPC messages must be on a single line. Multi-line JSON will cause parse errors.
|
365
|
+
|
366
|
+
### Testing in AI Assistant
|
367
|
+
|
368
|
+
Once configured, try these prompts in your AI assistant:
|
369
|
+
|
370
|
+
1. **Basic connectivity:**
|
371
|
+
```
|
372
|
+
Using simplecov-mcp, show me the version.
|
373
|
+
```
|
374
|
+
|
375
|
+
2. **List tools:**
|
376
|
+
```
|
377
|
+
Using simplecov-mcp, what tools are available?
|
378
|
+
```
|
379
|
+
|
380
|
+
3. **Simple query:**
|
381
|
+
```
|
382
|
+
Using simplecov-mcp, show me all files with coverage.
|
383
|
+
```
|
384
|
+
|
385
|
+
If these work, your setup is correct!
|
386
|
+
|
387
|
+
### Checking Logs
|
388
|
+
|
389
|
+
The MCP server logs to `simplecov_mcp.log` in the current directory by default.
|
390
|
+
|
391
|
+
```sh
|
392
|
+
# Watch logs in real-time
|
393
|
+
tail -f simplecov_mcp.log
|
394
|
+
|
395
|
+
# View recent errors
|
396
|
+
grep ERROR simplecov_mcp.log | tail -20
|
397
|
+
```
|
398
|
+
|
399
|
+
**Configure custom log location** when adding the server:
|
400
|
+
|
401
|
+
```sh
|
402
|
+
# Claude Code
|
403
|
+
claude mcp add simplecov-mcp simplecov-mcp --log-file /var/log/simplecov.log
|
404
|
+
|
405
|
+
# Codex
|
406
|
+
codex mcp add simplecov-mcp --command simplecov-mcp --args "--log-file" --args "/var/log/simplecov.log"
|
407
|
+
|
408
|
+
# Log to stderr (Claude)
|
409
|
+
claude mcp add simplecov-mcp simplecov-mcp --log-file stderr
|
410
|
+
```
|
411
|
+
|
412
|
+
**Note:** Logging to `stdout` is not permitted in MCP mode.
|
413
|
+
|
414
|
+
## Troubleshooting
|
415
|
+
|
416
|
+
### CLI Fallback
|
417
|
+
|
418
|
+
**Important:** If the MCP server doesn't work, use CLI commands with `--json` for structured output:
|
419
|
+
|
420
|
+
```sh
|
421
|
+
simplecov-mcp summary lib/file.rb --json # coverage_summary_tool
|
422
|
+
simplecov-mcp uncovered lib/file.rb --json # uncovered_lines_tool
|
423
|
+
simplecov-mcp detailed lib/file.rb --json # coverage_detailed_tool
|
424
|
+
simplecov-mcp list --json # all_files_coverage_tool
|
425
|
+
simplecov-mcp version --json # version_tool
|
426
|
+
```
|
427
|
+
|
428
|
+
See [CLI Usage](CLI_USAGE.md) for complete documentation.
|
429
|
+
|
430
|
+
### Common Issues
|
431
|
+
|
432
|
+
**Server Won't Start**
|
433
|
+
```sh
|
434
|
+
which simplecov-mcp # Verify executable exists
|
435
|
+
ruby -v # Check Ruby >= 3.2
|
436
|
+
simplecov-mcp version # Test basic functionality
|
437
|
+
```
|
438
|
+
|
439
|
+
**Path Issues with Version Managers**
|
440
|
+
```sh
|
441
|
+
which simplecov-mcp # Use this absolute path in MCP config
|
442
|
+
# RVM: Create wrapper for stability
|
443
|
+
rvm wrapper ruby-3.3.8 simplecov-mcp simplecov-mcp
|
444
|
+
```
|
445
|
+
|
446
|
+
**Tools Not Appearing**
|
447
|
+
1. Restart AI assistant after config changes
|
448
|
+
2. Check logs: `tail -f simplecov_mcp.log`
|
449
|
+
3. Try explicit tool names in prompts
|
450
|
+
4. Verify MCP server status in assistant
|
451
|
+
|
452
|
+
**JSON-RPC Parse Errors**
|
453
|
+
- Ensure JSON is on a single line (no newlines)
|
454
|
+
- Test manually: `echo '{"jsonrpc":"2.0",...}' | simplecov-mcp`
|
455
|
+
|
456
|
+
## Advanced Configuration
|
457
|
+
|
458
|
+
### Enable Debug Logging
|
459
|
+
|
460
|
+
For troubleshooting, add error mode when configuring the server:
|
461
|
+
|
462
|
+
```sh
|
463
|
+
# Claude Code
|
464
|
+
claude mcp add simplecov-mcp simplecov-mcp --error-mode trace
|
465
|
+
|
466
|
+
# Codex
|
467
|
+
codex mcp add simplecov-mcp --command simplecov-mcp --args "--error-mode" --args "trace"
|
468
|
+
|
469
|
+
# Gemini
|
470
|
+
gemini mcp add simplecov-mcp "$(which simplecov-mcp) --error-mode trace"
|
471
|
+
```
|
472
|
+
|
473
|
+
### Project-Specific vs. Global Configuration
|
474
|
+
|
475
|
+
**Global configuration** (all projects):
|
476
|
+
- Claude: `claude mcp add --scope user simplecov-mcp ...`
|
477
|
+
- Codex: `codex mcp add` (uses global config by default)
|
478
|
+
- Gemini: `gemini mcp add` (uses global config)
|
479
|
+
|
480
|
+
**Project-specific** (one project):
|
481
|
+
- Claude: `claude mcp add --scope project simplecov-mcp ...` (default is `local`)
|
482
|
+
- Codex/Gemini: Create `.codex/config.toml` or `.gemini/config.toml` in project root (manual)
|
483
|
+
|
484
|
+
## Next Steps
|
485
|
+
|
486
|
+
- **[CLI Usage](CLI_USAGE.md)** - Alternative to MCP for direct queries
|
487
|
+
- **[Examples](EXAMPLES.md)** - Example prompts and workflows
|
488
|
+
- **[Troubleshooting](TROUBLESHOOTING.md)** - Detailed troubleshooting guide
|