Repository navigation
feat(server): migrate to MCP SDK v2 MCPServer API - #17
Open
zxkjack123 wants to merge 9 commits into
Open
zxkjack123 wants to merge 9 commits into
zxkjack123 wants to merge 9 commits into
Conversation
…resolve() When para_id is explicitly provided, _resolve() no longer rejects the operation because the same text appears in other paragraphs. The paragraph-level dedup (multiple matches within one paragraph without context) is preserved. Closes SecurityRonin#6
This merges the fix for SecurityRonin#6 (remove document-global uniqueness guard from _resolve()) into our local main so we can use the patched version immediately. The feature branch remains available for the upstream PR. PR: SecurityRonin#11
When tracked=True, wraps existing w:r elements in w:del and appends new text in w:ins, producing proper revision markup. tracked=False preserves the existing silent-update behavior. Closes SecurityRonin#9
Adds tracked=True support to update_paragraph (Closes SecurityRonin#9). Branch retained for upstream PR.
…e_image Both tools now accept document_handle: str = '' for concurrent session isolation. Empty string continues to use __default__ slot. Closes SecurityRonin#8
Adds document_handle to copy_document and update_image (Closes SecurityRonin#8). Branch retained for upstream PR.
MCP SDK 2.0.0 removed mcp.server.fastmcp (FastMCP renamed to MCPServer). Unpinned mcp>=1.0.0 lets fresh installs resolve to 2.0.0 and die on import. Pin to the v1 maintenance line until migration to MCPServer API is done (see issue SecurityRonin#14). Closes SecurityRonin#14
Pins mcp>=1.28,<2 (Closes SecurityRonin#14). Branch retained for upstream PR.
- FastMCP -> MCPServer (from mcp.server import MCPServer) - 219 @mcp.tool() decorators unchanged (v2-compatible per migration guide) - Add threading.RLock around _docs dict (v2 runs sync handlers on worker threads) - Pin mcp>=2,<3 Supersedes the mcp>=1.28,<2 pin from PR SecurityRonin#16. Known limitation: same-handle concurrent edits are not serialized (documented).
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This branch has not been deployed
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.
Summary
Migrates docx-mcp from MCP SDK v1 (
mcp.server.fastmcp.FastMCP) to v2 (mcp.server.MCPServer). This supersedes themcp>=1.28,<2pin from PR #16.Migration surface (audited, not estimated)
from mcp.server import MCPServerFastMCP(→MCPServer((args unchanged)@mcp.tool()decoratorsmcp>=2,<3Verified zero hits for the migration guide's high-risk items:
mcp.typesimports, camelCase fields,get_context(),McpError,.rootaccess, constructor transport params,MCP_*env vars, httpx dependency.Thread safety
v2 runs sync handlers on worker threads (v1 ran them on the event loop, which accidentally serialized them). docx-mcp has 225 sync tools sharing the global
_docsdict, so this PR adds athreading.RLockguarding all_docsaccess points (_resolve,_store,close_document, the_Module._doccompat property). Filesystem cleanup (doc.close()) runs outside the lock.Known limitation (documented): same-handle concurrent edits are not serialized. This matches the existing instructions ("unsafe for parallel ones") and LLM clients' serialized tool-call pattern. Per-document serialization can be a follow-up if real usage shows a need.
Test results
Smoke test with the v2 official
Client(in-process):Real tool call returns a clean tool error (not a crash) when no document is open.
Notes
Closes #14