Skip to main content
Glama
onsecurity
by onsecurity

get-notifications

Retrieve summarized notifications from OnSecurity with customizable sorting, filtering, and pagination options for clear client understanding.

Instructions

Get all notifications data from OnSecurity from client in a high level summary, only include the summary, not the raw data and be sure to present the data in a way that is easy to understand for the client.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sortNoOptional sort parameter (e.g. 'created_at-desc' for newest first)
limitNoOptional limit parameter (e.g. 10 for 10 notifications per page)
pageNoOptional page number to fetch (default: 1)
includesNoOptional related data to include
fieldsNoOptional comma-separated list of fields to return (e.g. 'heading,created_at')
filtersNoOptional additional filters in format {field: value} or {field-operator: value} where operator can be mt (more than), mte (more than equal), lt (less than), lte (less than equal), eq (equals, default)

Implementation Reference

  • The main execution logic for the get-notifications tool. It processes input parameters, applies filters, fetches notification data from the OnSecurity API via fetchPage, formats the results using formatNotification and formatPaginationInfo, and returns a structured markdown text response.
    async (params) => {
        const filters: Record<string, string | number> = {};
        
        // Add additional filters if provided
        if (params.filters) {
            Object.entries(params.filters).forEach(([key, value]) => {
                filters[key] = value;
            });
        }
        
        const response = await fetchPage<ApiResponse<NotificationFeature>>(
            'notifications', 
            params.page || 1, 
            filters, 
            params.sort, 
            params.includes, 
            params.fields, 
            params.limit
        );
        
        if (!response) {
            return {
                content: [
                    {
                        type: "text",
                        text: "Error fetching notifications data. Please try again."
                    }
                ]
            };
        }
        
        const paginationInfo = formatPaginationInfo(response);
        const formattedNotifications = response.result.map(formatNotification);
        
        const responseText = [
            "# Notifications Summary",
            "",
            "## Pagination Information",
            paginationInfo,
            "",
            "## Notifications Data",
            ...formattedNotifications
        ].join('\n');
    
        return {
            content: [
                {
                    type: "text",
                    text: responseText
                }
            ]
        };
    }
  • Zod schema defining the input parameters for the get-notifications tool, including pagination, sorting, filtering, and field selection options.
    {
        sort: z.string().optional().describe("Optional sort parameter (e.g. 'created_at-desc' for newest first)"),
        limit: z.number().optional().describe("Optional limit parameter (e.g. 10 for 10 notifications per page)"),
        page: z.number().optional().describe("Optional page number to fetch (default: 1)"),
        includes: z.string().optional().describe("Optional related data to include"),
        fields: z.string().optional().describe("Optional comma-separated list of fields to return (e.g. 'heading,created_at')"),
        filters: FilterSchema,
    },
  • src/index.ts:522-586 (registration)
    The server.tool call that registers the 'get-notifications' tool with the MCP server, including its name, description, input schema, and handler function.
    server.tool(
        "get-notifications",
        "Get all notifications data from OnSecurity from client in a high level summary, only include the summary, not the raw data and be sure to present the data in a way that is easy to understand for the client.",
        {
            sort: z.string().optional().describe("Optional sort parameter (e.g. 'created_at-desc' for newest first)"),
            limit: z.number().optional().describe("Optional limit parameter (e.g. 10 for 10 notifications per page)"),
            page: z.number().optional().describe("Optional page number to fetch (default: 1)"),
            includes: z.string().optional().describe("Optional related data to include"),
            fields: z.string().optional().describe("Optional comma-separated list of fields to return (e.g. 'heading,created_at')"),
            filters: FilterSchema,
        },
        async (params) => {
            const filters: Record<string, string | number> = {};
            
            // Add additional filters if provided
            if (params.filters) {
                Object.entries(params.filters).forEach(([key, value]) => {
                    filters[key] = value;
                });
            }
            
            const response = await fetchPage<ApiResponse<NotificationFeature>>(
                'notifications', 
                params.page || 1, 
                filters, 
                params.sort, 
                params.includes, 
                params.fields, 
                params.limit
            );
            
            if (!response) {
                return {
                    content: [
                        {
                            type: "text",
                            text: "Error fetching notifications data. Please try again."
                        }
                    ]
                };
            }
            
            const paginationInfo = formatPaginationInfo(response);
            const formattedNotifications = response.result.map(formatNotification);
            
            const responseText = [
                "# Notifications Summary",
                "",
                "## Pagination Information",
                paginationInfo,
                "",
                "## Notifications Data",
                ...formattedNotifications
            ].join('\n');
    
            return {
                content: [
                    {
                        type: "text",
                        text: responseText
                    }
                ]
            };
        }
    );
  • Utility function specifically used by the get-notifications handler to format individual notification data into a readable string.
    function formatNotification(notification: NotificationFeature): string {
        return [
            `Content: ${notification.heading}`,
            `Created At: ${notification.created_at}`,
            `Updated At: ${notification.updated_at}`,
            `--------------------------------`,
        ].join('\n');
  • TypeScript interfaces defining the structure of NotificationFeature (single notification) and NotificationResponse (paginated API response), used for type safety in the tool implementation.
    export interface NotificationFeature {
        heading?: string;
        created_at?: string;
        updated_at?: string;
    }
    
    export interface NotificationResponse {
        links: {
            self: string;
            first: string;
            next: string | null;
            previous: string | null;
            last: string;
        };
        limit: number;
        sort: null;
        includes: any[];
        total_results: number;
        total_pages: number;
        page: number;
        result: NotificationFeature[];
    }

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/onsecurity/onsecurity-mcp-server'

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