{"record":{"id":"3855db415218bed6","repo":"affaan-m/ECC","slug":"invalid-name-provided","errorCode":null,"errorMessage":"Invalid name provided","messagePattern":"Invalid name provided","errorType":"exception","errorClass":"MCPException","httpStatus":null,"severity":"error","filePath":"skills/tinystruct-patterns/SKILL.md","lineNumber":170,"sourceCode":"import org.tinystruct.system.annotation.Argument;\n\npublic class MyCustomTool extends MCPTool {\n    public MyCustomTool() {\n        super(\"custom\", \"A custom tool for demonstrating MCP\");\n    }\n\n    @Action(\n        value = \"custom/hello\",\n        description = \"Say hello to someone\",\n        arguments = {\n            @Argument(key = \"name\", description = \"The name to greet\", type = \"string\", optional = false)\n        }\n    )\n    public String hello(String name) throws MCPException {\n        // SECURITY: Validate/sanitize tool inputs before returning to the model\n        // to prevent prompt injection vulnerabilities.\n        if (name == null || name.length() > 50 || !name.matches(\"^[a-zA-Z0-9 ]+$\")) {\n            throw new MCPException(\"Invalid name provided\");\n        }\n        return \"Hello, \" + name + \"!\";\n    }\n}\n```\n\n**To deploy an MCP Server:**\n1. Extend `org.tinystruct.mcp.MCPServer`.\n2. Override `init()` and register your tools using `this.registerTool()`. The framework automatically scans and maps the `@Action` methods.\n\n```java\nimport org.tinystruct.mcp.MCPServer;\n\npublic class MyMCPServer extends MCPServer {\n    @Override\n    public void init() {\n        super.init();\n        this.registerTool(new MyCustomTool());","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/tinystruct-patterns/SKILL.md#L152-L188","documentation":"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.","triggerScenarios":"Thrown at skills/tinystruct-patterns/SKILL.md:170 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Apply schema validation (length, charset) to every tool argument","Escape or strip control characters before echoing input back to the model","Return a structured validation error the MCP client can display"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}