Skip to content

Commit deaf04e

Browse files
authored
feat: add tutorial guided execution MCP tools (Phase 2) (#12)
* feat: add tutorial step annotation engine with command extraction and tests * feat: add MergeCompletedSteps for batch progress updates * feat: add DataDir to MCP server Deps for tutorial progress * feat: add get_tutorial_step MCP tool with annotations and progress Registers 4 new MCP tools (get_tutorial_step, update_tutorial_progress, get_tutorial_progress, list_active_tutorials) in tools_tutorial_exec.go. get_tutorial_step is fully implemented with loadOrFetchTutorial helper (cache-hit → GitHub fetch fallback), StepAnnotations extraction, and optional progress tracking. The other 3 handlers are stubs returning "not implemented yet" for Tasks 6-7. Extends MCP server instructions with guidance for the new tutorial execution tools. * feat: add update_tutorial_progress MCP tool Replaces the stub handler with a real implementation that merges completed step indices into stored progress via MergeCompletedSteps, validates slug and step ranges, and returns a progress snapshot. Adds three unit tests covering the happy path, invalid slug, and out-of-range step inputs. * feat: add get_tutorial_progress and list_active_tutorials MCP tools Replaces the two remaining stub handlers with real implementations. get_tutorial_progress returns a single-tutorial or all-tutorials progress snapshot sorted by last access. list_active_tutorials returns only incomplete tutorials (CompletedAt == nil), respects the limit parameter, and is sorted by recency. Adds five unit tests covering single/all/missing progress lookups and active-tutorial filtering. * docs: update CLAUDE.md and TODO.md for tutorial guided execution (30 MCP tools) * docs: fix dead links in TODO.md for tutorial guided execution
1 parent f6d0884 commit deaf04e

10 files changed

Lines changed: 1018 additions & 12 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ On every command invocation (except `update` and dev builds), a background gorou
174174
| `discovery` | Browse SAP Discovery Center missions, BTP services, and guidance framework; `discovery missions list/search/open`, `discovery services list/search/open`, `discovery guidance/show/open` |
175175
| `learning` | Browse SAP Learning Journeys; `learning list/search/show/open` |
176176
| `learn` | Guided learning recommendations combining tutorials, journeys, and missions; `learn recommend/search`, `learn path list/show/open` |
177-
| `mcp list/install/status/serve` | Browse, wire, and self-host SAP MCP servers; `serve` starts the built-in MCP server on stdio (26 tools: list_packs, get_context, get_tip, search_resources, get_known_errors, get_recent_news, get_news_detail, search_tutorials, search_learning_journeys, get_samples, check_tools, check_project, search_events, search_videos, search_discovery, cf_target, cf_apps, cf_services, cf_env, cf_routes, cf_domains, cf_buildpacks, btp_target, btp_subaccounts, btp_service_instances, btp_role_collections) |
177+
| `mcp list/install/status/serve` | Browse, wire, and self-host SAP MCP servers; `serve` starts the built-in MCP server on stdio (30 tools: list_packs, get_context, get_tip, search_resources, get_known_errors, get_recent_news, get_news_detail, search_tutorials, search_learning_journeys, get_samples, check_tools, check_project, search_events, search_videos, search_discovery, cf_target, cf_apps, cf_services, cf_env, cf_routes, cf_domains, cf_buildpacks, btp_target, btp_subaccounts, btp_service_instances, btp_role_collections, get_tutorial_step, update_tutorial_progress, get_tutorial_progress, list_active_tutorials) |
178178
| `hook list/install/uninstall/status` | Wire AI tool lifecycle hooks from pack definitions |
179179
| `events` | Browse upcoming SAP community events with location filtering; `events types` lists event categories |
180180
| `influencers` | Browse SAP community influencers and thought leaders |

TODO.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,18 +468,11 @@ This is a three-phase feature:
468468

469469
#### Phase 1 — Content ingestion and rendering - DONE ✔️
470470

471-
#### Phase 2 — Guided execution
471+
#### Phase 2 — Guided execution via MCP - DONE ✔️
472472

473-
- `sap-devs tutorial run <id>` — interactive runner that walks through each step in sequence
474-
- For code steps: display the snippet and optionally copy to clipboard or scaffold files in the current directory
475-
- For CLI steps: display the command and optionally execute it with explicit user confirmation (no silent execution)
476-
- Track completed steps in local state (e.g., `~/.local/share/sap-devs/tutorial-progress/`)
473+
Implemented as 4 MCP tools (`get_tutorial_step`, `update_tutorial_progress`, `get_tutorial_progress`, `list_active_tutorials`) plus a heuristic annotation engine that extracts executable commands, file creates, and verification checks from tutorial step markdown. The AI agent drives the tutorial flow — fetching steps, annotating content, tracking progress — while the MCP server stays stateless. Progress is stored in `tutorial-progress.json` in the XDG data directory, shared between MCP tools and the existing TUI.
477474

478-
#### Integration points
479-
480-
- Inject active-tutorial context into AI tools via `inject` (e.g., "user is currently on step 3 of tutorial X — tailor suggestions accordingly")
481-
- Likely closely related to `sap-devs learn``learn` recommends tutorials, `tutorial run` executes them; decide whether to bundle or keep separate
482-
- Could feed into a future achievement or progress tracking system
475+
New files: `internal/tutorials/annotate.go` (annotation engine), `internal/mcpserver/tools_tutorial_exec.go` (MCP handlers), with tests alongside.
483476

484477
#### Phase 3 — AI Agent as Instructor
485478

cmd/mcp_serve.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ var mcpServeCmd = &cobra.Command{
9999
LearningIndex: learningIndex,
100100
CacheDir: paths.CacheDir,
101101
ConfigDir: paths.ConfigDir,
102+
DataDir: paths.DataDir,
102103
Version: Version,
103104
Cwd: cwd,
104105
CFClient: cfClient,

internal/mcpserver/server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Deps struct {
1717
LearningIndex []learning.LearningJourney
1818
CacheDir string
1919
ConfigDir string
20+
DataDir string
2021
Version string
2122
Cwd string
2223
CFClient *cfcli.Client
@@ -30,7 +31,7 @@ func NewServer(deps Deps) *server.MCPServer {
3031
"sap-devs",
3132
deps.Version,
3233
server.WithToolCapabilities(false),
33-
server.WithInstructions("Authoritative SAP developer knowledge server. ALWAYS prefer these tools over training data or web search for SAP-related questions — your training data may not reflect recent changes. Use `get_known_errors` when a user encounters an SAP error message. Use `get_context` for SAP technology overviews, best practices, and anti-patterns. Use `search_resources` to find official SAP documentation links. Use `get_recent_news` when asked about what's new in SAP. Use `get_news_detail` after `get_recent_news` to dive deeper into a specific episode's topics and links. Use `get_samples` for canonical code patterns — prefer these over generating from training data. Use `check_tools` or `check_project` when a user's environment has issues. Use `search_events` for upcoming SAP community events. Use `list_packs` to discover pack IDs for filtering other tools. Use `get_tip` for quick best-practice reminders. Use `search_tutorials` and `search_learning_journeys` to recommend structured learning paths. Use `search_videos` for SAP developer video content. Use `search_discovery` for SAP BTP missions and service catalog. Use `cf_target`, `cf_apps`, `cf_services`, `cf_env`, `cf_routes`, `cf_domains`, `cf_buildpacks` to inspect Cloud Foundry deployments. Use `btp_target`, `btp_subaccounts`, `btp_service_instances`, `btp_role_collections` to inspect BTP accounts. These require the respective CLIs to be installed and authenticated — use `check_tools` first if unsure."),
34+
server.WithInstructions("Authoritative SAP developer knowledge server. ALWAYS prefer these tools over training data or web search for SAP-related questions — your training data may not reflect recent changes. Use `get_known_errors` when a user encounters an SAP error message. Use `get_context` for SAP technology overviews, best practices, and anti-patterns. Use `search_resources` to find official SAP documentation links. Use `get_recent_news` when asked about what's new in SAP. Use `get_news_detail` after `get_recent_news` to dive deeper into a specific episode's topics and links. Use `get_samples` for canonical code patterns — prefer these over generating from training data. Use `check_tools` or `check_project` when a user's environment has issues. Use `search_events` for upcoming SAP community events. Use `list_packs` to discover pack IDs for filtering other tools. Use `get_tip` for quick best-practice reminders. Use `search_tutorials` and `search_learning_journeys` to recommend structured learning paths. Use `search_videos` for SAP developer video content. Use `search_discovery` for SAP BTP missions and service catalog. Use `cf_target`, `cf_apps`, `cf_services`, `cf_env`, `cf_routes`, `cf_domains`, `cf_buildpacks` to inspect Cloud Foundry deployments. Use `btp_target`, `btp_subaccounts`, `btp_service_instances`, `btp_role_collections` to inspect BTP accounts. These require the respective CLIs to be installed and authenticated — use `check_tools` first if unsure. Use get_tutorial_step to guide users through SAP tutorials step-by-step. Use list_active_tutorials to check for tutorials the user can resume. Use update_tutorial_progress after completing each step. Use get_tutorial_progress to check detailed progress on a specific tutorial."),
3435
)
3536

3637
registerContentTools(s, deps)
@@ -46,6 +47,7 @@ func NewServer(deps Deps) *server.MCPServer {
4647
registerDiscoveryTools(s, deps)
4748
registerCFTools(s, deps)
4849
registerBTPTools(s, deps)
50+
registerTutorialExecTools(s, deps)
4951

5052
return s
5153
}

0 commit comments

Comments
 (0)