Skip to content

Conversation

4erdenko
Copy link

PR Title

feat(jira): support `additional_fields` as dict or JSON string

Summary

This patch lets the Jira FastMCP server accept additional_fields when it is passed either as a native dict or as a JSON‑encoded str. It removes validation failures that occurred when XML‑to‑JSON converters wrapped the object in quotes.


Rationale

External clients (e.g. Anthropic Claude, Cursor) often emit tool calls in an XML‑like format. During XML → JSON‑RPC conversion, a nested JSON object is injected as a plain string:

"additional_fields": "{\"priority\": {\"id\": \"2\"}}"

Pydantic rejected this with dict_type. Accepting the string and parsing it server‑side solves the problem without breaking existing callers that already send a dict.


Technical Details

  • additional_fields type hint updated to dict[str, Any] | str | None.
  • New branch parses a JSON string via json.loads; rejects invalid JSON or values that are not objects.
  • Error messages clarified.

Code excerpt:

if additional_fields is None:
    extra_fields = {}
elif isinstance(additional_fields, dict):
    extra_fields = additional_fields
elif isinstance(additional_fields, str):
    extra_fields = json.loads(additional_fields)
    if not isinstance(extra_fields, dict):
        raise ValueError("parsed additional_fields is not an object")
else:
    raise ValueError("additional_fields must be a dict or JSON string")

Tests

  • test_create_issue_additional_fields_str_ok – JSON string accepted, issue created.
  • test_create_issue_additional_fields_str_invalid – invalid JSON string returns clear ValueError.
  • Existing tests for dict input remain green.

Backward Compatibility

  • No breaking changes.
  • Calls that already send a dict behave exactly as before.
  • Calls that send a non‑JSON string still fail fast with a clear error.

Documentation

  • Docstring for create_issue updated.
  • If the public OpenAPI / tool schema is exported, change the field definition to:
"additional_fields": { "type": ["object", "string", "null"] }

Related Issues

Fixes: #

* feat: parse additional_fields as JSON string

Allow create_issue to accept dict or JSON string. Added test and docs.
Copy link

This pull request has been automatically marked as stale because it has not had recent activity for 14 days. It will be closed if no further activity occurs. Please leave a comment or remove the 'stale' label if you believe this PR is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale label Aug 11, 2025
@4erdenko
Copy link
Author

Up.

@github-actions github-actions bot removed the stale label Aug 12, 2025
@makotarifa
Copy link

Works well!! Lets move this up 👍🏻

Copy link

This pull request has been automatically marked as stale because it has not had recent activity for 14 days. It will be closed if no further activity occurs. Please leave a comment or remove the 'stale' label if you believe this PR is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale label Aug 31, 2025
@4erdenko
Copy link
Author

4erdenko commented Sep 8, 2025

@sooperset check this please

@github-actions github-actions bot removed the stale label Sep 9, 2025
@mliq
Copy link

mliq commented Sep 11, 2025

please yes - this fixes create_issue. Still issues with update_issue though. Would it be possible to include that fix? I will work on it and make a new PR crediting @4erdenko for this work.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity for 14 days. It will be closed if no further activity occurs. Please leave a comment or remove the 'stale' label if you believe this PR is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale label Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants