get_details
Retrieve OTP token details by searching with a pattern to find specific tokens for authentication needs.
Instructions
Get the details of all the OTP tokens 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:84-95 (handler)The main handler function for the 'get_details' MCP tool, registered via @mcp.tool() decorator. It finds matching OTP tokens using the find_tokens helper and formats their details using format_token.@mcp.tool() async def get_details(pattern: str) -> str: """ Get the details of all the OTP tokens matching the pattern Args: pattern: Token pattern (part of the name or token number) """ tokens_list = find_tokens(pattern) if not tokens_list: raise ToolError("No OTP tokens found.") return "\n---\n".join([format_token(x) for x in tokens_list])
- otp_mcp/tool.py:36-49 (helper)Helper function used by get_details (and other tools) to find OTP tokens in the database that match 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
- otp_mcp/tool.py:52-68 (helper)Helper function used by get_details (and potentially others) to format the details of a single OTP token into a readable string.def format_token(token: Token) -> str: """ Format the token details for display. """ result: list[str] = [ f"Id: {token.rowid}#", f"Type: {token.type.name}", f"Algorithm: {token.algorithm}", f"Issuer: {token.issuer}", f"Account: {token.label}", f"Digits: {token.digits}", ] if token.type == TokenType.HOTP: result.append(f"Counter: {token.counter}") else: result.append(f"Period: {token.period} seconds") return "\n".join(result)