feat(angular-mcp-server): add get_ds_story_data MCP tool#28
Merged
Karnaukhov-kh merged 7 commits intomainfrom Apr 14, 2026
Merged
feat(angular-mcp-server): add get_ds_story_data MCP tool#28Karnaukhov-kh merged 7 commits intomainfrom
Karnaukhov-kh merged 7 commits intomainfrom
Conversation
poltorak
reviewed
Apr 9, 2026
packages/angular-mcp-server/src/lib/tools/ds/story-parser/utils/story-parser.utils.ts
Show resolved
Hide resolved
poltorak
approved these changes
Apr 10, 2026
There was a problem hiding this comment.
Pull request overview
Adds a new get-ds-story-data tool to the Angular MCP server to extract structured, token-efficient usage information from Storybook .stories.ts files (selector style, inputs/argTypes, slots, form bindings, and cleaned templates), with supporting shared parsing utilities and documentation updates.
Changes:
- Introduces
get-ds-story-datatool + story parsing/markdown formatting utilities and tests. - Adds shared low-level helpers (
escapeRegex, source-text extraction utilities) and wires them into existing DS utilities. - Updates tooling documentation and recommended planning workflow to include the new tool.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/utils/src/lib/regex.utils.ts | Adds shared escapeRegex helper for safe dynamic regex building. |
| packages/shared/utils/src/index.ts | Exports the new regex utility from @push-based/utils. |
| packages/shared/typescript-ast-utils/src/lib/source-text.utils.ts | Adds source-text extractors for template literals and balanced blocks. |
| packages/shared/typescript-ast-utils/src/index.ts | Exposes the new source-text helpers via package exports. |
| packages/angular-mcp-server/src/lib/tools/ds/tools.ts | Registers the new DS story tool in the MCP server tool set. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/utils/story-parser.utils.ts | Implements story parsing (AST-first + regex helpers) and data extraction. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/utils/story-markdown-formatter.utils.ts | Adds compact markdown formatting for parsed story data. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/utils/tests/story-parser.utils.spec.ts | Adds unit tests for parsing/cleaning/selector/form detection. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/models/types.ts | Defines structured output types for the new tool. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/index.ts | Exports the new tool module entrypoint. |
| packages/angular-mcp-server/src/lib/tools/ds/story-parser/get-ds-story-data.tool.ts | Implements the MCP tool schema + handler (file resolution, filtering, formatting). |
| packages/angular-mcp-server/src/lib/tools/ds/shared/utils/template-helpers.ts | Adds template cleaning and selector/form/slot detection helpers. |
| packages/angular-mcp-server/src/lib/tools/ds/shared/utils/regex-helpers.ts | Reuses shared escapeRegex instead of local duplication. |
| packages/angular-mcp-server/src/lib/tools/ds/project/utils/styles-report-helpers.ts | Reuses shared escapeRegex instead of local duplication. |
| docs/tools.md | Documents get-ds-story-data and inserts it into the recommended workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/shared/typescript-ast-utils/src/lib/source-text.utils.ts
Outdated
Show resolved
Hide resolved
packages/angular-mcp-server/src/lib/tools/ds/story-parser/utils/story-parser.utils.ts
Show resolved
Hide resolved
.../angular-mcp-server/src/lib/tools/ds/story-parser/utils/__tests__/story-parser.utils.spec.ts
Outdated
Show resolved
Hide resolved
poltorak
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
During migration, an AI agent needs to understand how a component is actually used, not just its TypeScript API.
The existing get_ds_component_data tool returns file paths to implementation and docs, but the agent still has to read and parse the raw .stories.ts file itself. For some components, that means working through a 28K file with 17 stories, most of which are Storybook showcase stories that are irrelevant for migration.
This tool closes that gap by parsing the story file and returning only the information the agent actually needs: selector style, input API with defaults, slots, form integration patterns, and real usage templates — at only 12–26% of the raw file size.
Template Cleaning
Output Parameters
Size Comparison (default filtering)
What
This pull request introduces a new tool,
get-ds-story-data, to the Angular MCP server. The tool allows AI agents and developers to extract structured information and usage patterns from Storybook.stories.tsfiles for Design System (DS) components. It includes both code and documentation updates, as well as supporting types and utilities to enable markdown or JSON output. The tool is integrated into the main DS tools collection and referenced in the planning workflow.Key additions and changes:
New Tool: Story Data Extraction
get-ds-story-datatool, which parses Storybook.stories.tsfiles for a given DS component and outputs a compact summary of its API surface, usage patterns, and story templates. The tool supports filtering by story tags, short/full descriptions, and output in markdown or JSON format.models/types.ts.Integration
Documentation
docs/tools.mdto document the new tool's purpose, parameters, and best practices, and to include it in the recommended planning workflow for AI agents. [1] [2]