Skip to content

Code samples get formatted incorrectly #18

@G4Vi

Description

@G4Vi

In mcp.run the schema has the code sample as such and it looks correctly formatted:

- lang: python
        label: Description of a simple greeting tool that greets someone by name
        source: |
          name = input.params.name
          if name is None:
              raise Exception("Argument `name` must be provided")
          return CallToolResult(
              content=[
                  Content(
                      text=f'Hello, {name}',
                      mimeType="text/plain",
                      type=ContentType.Text,
                      annotations=None,
                      data=None,
                  )
              ],
              isError=False,
          )

After xtp plugin init --feature stub-with-code-samples,
the python has incorrect indentation and does not build.

def call(input: CallToolRequest) -> CallToolResult:
    name = input.params.name


if name is None:
    raise Exception("Argument `name` must be provided")
return CallToolResult(
    content=[
        Content(
            text=f"Hello, {name}",
            mimeType="text/plain",
            type=ContentType.Text,
            annotations=None,
            data=None,
        )
    ],
    isError=False,
)

I did not have to reformat the describe export.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions