affaan-m/ECC · error · MCPException

Invalid name provided

Error message

Invalid name provided

What it means

Illustrative input-sanitization guard in a tinystruct MCP tool example: the tool validates its `name` argument before returning it to the model and throws on an invalid value. The unvalidated tool input (the name parameter) is the faulty input; the comment marks this as a prompt-injection defense.

Solutions

  1. Apply schema validation (length, charset) to every tool argument
  2. Escape or strip control characters before echoing input back to the model
  3. Return a structured validation error the MCP client can display
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at skills/tinystruct-patterns/SKILL.md:170 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@d8409a4b08 (2026-08-26). Data as JSON: /api/errors/3855db415218bed6. Report an issue: GitHub.

Appendix: source

Thrown at skills/tinystruct-patterns/SKILL.md:170

import org.tinystruct.system.annotation.Argument;

public class MyCustomTool extends MCPTool {
    public MyCustomTool() {
        super("custom", "A custom tool for demonstrating MCP");
    }

    @Action(
        value = "custom/hello",
        description = "Say hello to someone",
        arguments = {
            @Argument(key = "name", description = "The name to greet", type = "string", optional = false)
        }
    )
    public String hello(String name) throws MCPException {
        // SECURITY: Validate/sanitize tool inputs before returning to the model
        // to prevent prompt injection vulnerabilities.
        if (name == null || name.length() > 50 || !name.matches("^[a-zA-Z0-9 ]+$")) {
            throw new MCPException("Invalid name provided");
        }
        return "Hello, " + name + "!";
    }
}
```

**To deploy an MCP Server:**
1. Extend `org.tinystruct.mcp.MCPServer`.
2. Override `init()` and register your tools using `this.registerTool()`. The framework automatically scans and maps the `@Action` methods.

```java
import org.tinystruct.mcp.MCPServer;

public class MyMCPServer extends MCPServer {
    @Override
    public void init() {
        super.init();
        this.registerTool(new MyCustomTool());

View on GitHub (pinned to d8409a4b08)