Skip to content

Conversation

azu
Copy link
Member

@azu azu commented Jun 29, 2025

Overview

This PR enhances the MCP (Model Context Protocol) server by adding detailed descriptions to all Zod schemas in the textlint MCP server. These descriptions improve API documentation and make the server more user-friendly for MCP clients.

Changes

Schema Descriptions Added

Input Schemas:

  • filePaths: Added descriptions for file path arrays and individual file paths
  • text: Added description for text content to be linted/fixed
  • stdinFilename: Added description explaining its purpose as context (e.g., 'stdin.md')

Output Schemas:

  • severity: Added detailed description explaining the severity levels:
    • 1: warning - Issues that should be addressed but don't prevent processing
    • 2: error - Critical issues that need to be fixed
    • 3: info - Informational messages for guidance or suggestions
  • line: Added description clarifying it's 1-based indexing
  • column: Added description clarifying it's 1-based indexing
  • fix.range: Added description explaining it's 0-based text range [start, end]
  • fix.text: Added description as "Replacement text"
  • fix: Added description as "Fix suggestion if available"
  • output: Added descriptions for fixed content availability

Benefits

  1. Better API Documentation: MCP clients can now understand what each field represents and its expected format
  2. Improved Developer Experience: Clear descriptions help developers understand the textlint severity system and coordinate systems
  3. Enhanced Type Safety: Zod descriptions provide runtime validation documentation
  4. MCP Compliance: Follows MCP TypeScript SDK best practices for schema documentation

Tools Updated

All four MCP tools have been enhanced:

  • lintFile - Lint files using textlint
  • lintText - Lint text using textlint
  • getLintFixedFileContent - Get lint-fixed content of files
  • getLintFixedTextContent - Get lint-fixed content of text

Compatibility

This change is fully backward compatible as it only adds .describe() calls to existing Zod schemas without changing the actual validation logic or API structure.

References

@Copilot Copilot AI review requested due to automatic review settings June 29, 2025 15:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enriches API documentation by adding descriptive metadata to Zod schemas in the textlint MCP server.

  • Added .describe() calls to input schema fields to clarify expected values.
  • Added .describe() calls to output schema fields (line, column, severity, fix, output) for better client understanding.
  • Applied these enhancements uniformly across four MCP endpoints without altering validation logic.
Comments suppressed due to low confidence (3)

packages/textlint/src/mcp/server.ts:231

  • This description is inconsistent with other endpoints. Consider using "Fixed content if available" to match the pattern used elsewhere.
                        output: z.string().optional().describe("Fixed content")

packages/textlint/src/mcp/server.ts:295

  • This description is inconsistent with other endpoints. Consider using "Fixed content if available" for consistency.
                output: z.string().optional().describe("Fixed content"),

packages/textlint/src/mcp/server.ts:152

  • The filePath field in this output schema lacks a .describe() call; adding one would improve API documentation consistency.
                filePath: z.string(),

Comment on lines 90 to 103
z.object({
ruleId: z.string().optional(),
message: z.string(),
line: z.number(),
column: z.number(),
severity: z.number(),
line: z.number().describe("Line number (1-based)"),
column: z.number().describe("Column number (1-based)"),
severity: z.number().describe("Severity level: 1=warning, 2=error, 3=info"),
fix: z
.object({
range: z.array(z.number()),
text: z.string()
range: z.array(z.number()).describe("Text range [start, end] (0-based)"),
text: z.string().describe("Replacement text")
})
.optional()
.describe("Fix suggestion if available")
})
Copy link
Preview

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The message object schema is duplicated across multiple endpoints; consider extracting it into a shared constant to reduce repetition.

Copilot uses AI. Check for mistakes.

@azu azu added the Type: Feature New Feature label Jun 29, 2025
- Update outputSchema snapshot to include new descriptions for severity, line, column, fix fields
- Add comprehensive validation for input schema descriptions
- Add test to verify all tools have proper descriptions for severity levels
- Verify 1-based vs 0-based indexing documentation is correct
@azu azu merged commit e77ea85 into master Jun 30, 2025
17 checks passed
@azu azu deleted the mcp-describe branch June 30, 2025 13:02
@github-actions github-actions bot mentioned this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant