Skip to main content
Glama
descope-sample-apps

descope-mcp-server

Official

search-audits

Search and filter Descope project audit logs by login IDs, actions, tenants, methods, or geographic locations to monitor authentication activity and security events.

Instructions

Search Descope project audit logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
loginIdsNoFilter by specific login IDs
actionsNoFilter by specific action types
excludedActionsNoActions to exclude from results
tenantsNoFilter by specific tenant IDs
noTenantsNoIf true, only show events without tenants
methodsNoFilter by authentication methods
geosNoFilter by geographic locations
hoursBackNoHours to look back (max 720 hours / 30 days)
limitNoNumber of audit logs to fetch (max 10)

Implementation Reference

  • The asynchronous handler function that executes the search-audits tool. It searches Descope audit logs using the provided filters, limits the results, and returns a formatted text response.
    async ({ loginIds, actions, excludedActions, tenants, noTenants, methods, geos, hoursBack, limit }) => {
        try {
            const now = Date.now();
            const from = now - (hoursBack * 60 * 60 * 1000);
            const audits = await descope.management.audit.search({
                from,
                to: now,
                loginIds,
                actions,
                excludedActions,
                tenants,
                noTenants,
                methods,
                geos,
            });
    
            // Limit the number of audits to the specified limit
            const auditResponse = audits.data;
            const limitedAudits = auditResponse ? auditResponse.slice(0, limit) : [];
    
            return {
                content: [
                    {
                        type: "text",
                        text: `Audit logs for the last ${hoursBack} hours:\n\n${JSON.stringify(limitedAudits, null, 2)}`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Error fetching audit logs: ${error}`,
                    },
                ],
            };
        }
    },
  • Zod schema defining the input parameters and their descriptions for the search-audits tool.
    {
        // Optional filters
        loginIds: z.array(z.string()).optional()
            .describe("Filter by specific login IDs"),
        actions: z.array(z.string()).optional()
            .describe("Filter by specific action types"),
        excludedActions: z.array(z.string()).optional()
            .describe("Actions to exclude from results"),
        tenants: z.array(z.string()).optional()
            .describe("Filter by specific tenant IDs"),
        noTenants: z.boolean().optional()
            .describe("If true, only show events without tenants"),
        methods: z.array(z.string()).optional()
            .describe("Filter by authentication methods"),
        geos: z.array(z.string()).optional()
            .describe("Filter by geographic locations"),
        // Time range (defaults to last 24 hours)
        hoursBack: z.number().min(1).max(24 * 30).default(24)
            .describe("Hours to look back (max 720 hours / 30 days)"),
        // Limit (defaults to 5)
        limit: z.number().min(1).max(10).default(5)
            .describe("Number of audit logs to fetch (max 10)"),
    },
  • src/descope.ts:33-98 (registration)
    Registration of the 'search-audits' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool(
        "search-audits",
        "Search Descope project audit logs",
        {
            // Optional filters
            loginIds: z.array(z.string()).optional()
                .describe("Filter by specific login IDs"),
            actions: z.array(z.string()).optional()
                .describe("Filter by specific action types"),
            excludedActions: z.array(z.string()).optional()
                .describe("Actions to exclude from results"),
            tenants: z.array(z.string()).optional()
                .describe("Filter by specific tenant IDs"),
            noTenants: z.boolean().optional()
                .describe("If true, only show events without tenants"),
            methods: z.array(z.string()).optional()
                .describe("Filter by authentication methods"),
            geos: z.array(z.string()).optional()
                .describe("Filter by geographic locations"),
            // Time range (defaults to last 24 hours)
            hoursBack: z.number().min(1).max(24 * 30).default(24)
                .describe("Hours to look back (max 720 hours / 30 days)"),
            // Limit (defaults to 5)
            limit: z.number().min(1).max(10).default(5)
                .describe("Number of audit logs to fetch (max 10)"),
        },
        async ({ loginIds, actions, excludedActions, tenants, noTenants, methods, geos, hoursBack, limit }) => {
            try {
                const now = Date.now();
                const from = now - (hoursBack * 60 * 60 * 1000);
                const audits = await descope.management.audit.search({
                    from,
                    to: now,
                    loginIds,
                    actions,
                    excludedActions,
                    tenants,
                    noTenants,
                    methods,
                    geos,
                });
    
                // Limit the number of audits to the specified limit
                const auditResponse = audits.data;
                const limitedAudits = auditResponse ? auditResponse.slice(0, limit) : [];
    
                return {
                    content: [
                        {
                            type: "text",
                            text: `Audit logs for the last ${hoursBack} hours:\n\n${JSON.stringify(limitedAudits, null, 2)}`,
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error fetching audit logs: ${error}`,
                        },
                    ],
                };
            }
        },
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It doesn't indicate whether this is a read-only operation, what permissions might be required, whether results are paginated, or what format the audit logs will be returned in. The description merely restates the tool name without adding meaningful behavioral context beyond what's implied by 'Search'.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single four-word phrase that efficiently communicates the core function. There's no wasted language or unnecessary elaboration. The description is appropriately sized for a search tool with well-documented parameters in the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 9 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what audit logs contain, how results are structured, whether there are rate limits, or what authentication might be required. The agent would need to rely heavily on trial-and-error or external knowledge to use this tool effectively, especially given the lack of output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with each parameter clearly documented in the schema itself. The tool description adds no additional parameter information beyond what's already in the schema descriptions. According to the scoring guidelines, when schema_description_coverage is high (>80%), the baseline score is 3 even with no parameter information in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Search') and resource ('Descope project audit logs'), making the tool's purpose immediately understandable. However, it doesn't differentiate this audit log search tool from the sibling 'search-users' tool, which searches a different resource type. The description is specific about what's being searched but doesn't clarify the distinction from similar search operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance about when to use this tool versus alternatives. There's no mention of prerequisites, appropriate contexts, or comparison with sibling tools like 'search-users'. The agent must infer usage from the tool name and parameters alone, which is insufficient for optimal tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/descope-sample-apps/descope-mcp-server-stdio'

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