delete_token
Remove an OTP token by specifying a pattern to match the token name or number. Part of the otp-mcp-server for secure OTP management.
Instructions
Delete an OTP token matching the pattern.
Args:
pattern: Token pattern (part of the name or token number)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes |
Implementation Reference
- otp_mcp/tool.py:165-181 (handler)The main handler function for the 'delete_token' tool. It is decorated with @mcp.tool() which registers it with the MCP server. Finds matching tokens using find_tokens helper and deletes them from the database.@mcp.tool() async def delete_token(pattern: str) -> str: """ Delete an OTP token matching the pattern. Args: pattern: Token pattern (part of the name or token number) """ db = get_token_db() tokens = find_tokens(pattern) if not pattern: raise ToolError("Pattern cannot be empty.") if not tokens: raise ToolError("No OTP tokens found.") for token in tokens: db.delete() return f"{len(tokens)} tokens deleted."
- otp_mcp/tool.py:36-49 (helper)Helper function used by delete_token to find OTP tokens matching the given pattern.def find_tokens(pattern: str) -> list[Token]: """ Find tokens matching the given pattern. """ db = get_token_db() if not pattern: return db.get_tokens() tokens_list = [] pattern = pattern.lower() for token in db.get_tokens(): tmp = str(token).lower().strip() if pattern in tmp or pattern == f"{token.rowid}#": tokens_list.append(token) return tokens_list