Skip to main content
Glama
andreax79

otp-mcp-server

by andreax79

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
NameRequiredDescriptionDefault
patternYes

Implementation Reference

  • 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])
  • 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
  • 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)

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andreax79/otp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server