Skip to main content
Glama
Shaveen12

CSE MCP Server

by Shaveen12

Get Top Losers

get_top_losers

Retrieve the top 10 losing stocks from the Colombo Stock Exchange for the current trading day. Get real-time data on price declines and change percentages.

Instructions

Get the top 10 losing stocks in the CSE for the current trading day.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler function `getTopLosers()` that fetches top losing stocks from the CSE API endpoint 'https://www.cse.lk/api/topLooses' and returns mapped stock data (symbol, price, change, changePercentage).
    async function getTopLosers() {
      try {
        const response = await axios.post(
          'https://www.cse.lk/api/topLooses',
          {},
          {
            headers: {
              'Content-Type': 'application/json'
            },
            timeout: 10000
          }
        );
        
        const data = response.data || [];
        
        return data.map((item: any) => ({
          symbol: item.symbol,
          price: item.price,
          change: item.change,
          changePercentage: item.changePercentage
        }));
      } catch (error: any) {
        if (error.code === 'ECONNABORTED') {
          throw new Error('Request timed out. Please try again.');
        } else if (error.response) {
          throw new Error(`API error: ${error.response.status} - ${error.response.statusText}`);
        } else {
          throw new Error(`Network error: ${error.message}`);
        }
      }
    }
  • Schema definition for the tool. Input schema is empty (no inputs required).
    {
      title: "Get Top Losers",
      description: "Get the top 10 losing stocks in the CSE for the current trading day.",
      inputSchema: {}
    },
  • src/index.ts:509-552 (registration)
    Tool registration via `server.registerTool('get_top_losers', {...})` with the handler that formats and returns top losers data.
    server.registerTool(
      "get_top_losers",
      {
        title: "Get Top Losers",
        description: "Get the top 10 losing stocks in the CSE for the current trading day.",
        inputSchema: {}
      },
      async () => {
        try {
          const topLosers = await getTopLosers();
          
          const formattedLosers = topLosers.map((stock: any, index: number) => {
            const priceChangeSymbol = stock.change >= 0 ? '+' : '';
            return {
              rank: index + 1,
              symbol: stock.symbol,
              price: `Rs. ${stock.price.toFixed(2)}`,
              change: `${priceChangeSymbol}${stock.change.toFixed(2)}`,
              changePercentage: `${priceChangeSymbol}${stock.changePercentage.toFixed(2)}%`
            };
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                title: "Top 10 Losers",
                count: formattedLosers.length,
                losers: formattedLosers,
                lastUpdated: new Date().toISOString()
              }, null, 2)
            }]
          };
        } catch (error: any) {
          return {
            content: [{
              type: "text",
              text: `Error fetching top losers: ${error.message}`
            }],
            isError: true
          };
        }
      }
    );
Behavior3/5

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

The tool is a straightforward read operation. However, with no annotations, the description does not disclose behavioral details like whether data is real-time, delayed, or historical, or what happens if the market is closed. Basic transparency is provided but minimal.

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 a single, well-structured sentence that conveys all necessary information without extraneous words. It is front-loaded with the key action and resource.

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

Completeness4/5

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

For a simple tool with no parameters and no output schema, the description is mostly complete. However, it could be improved by noting what data fields are returned (e.g., ticker, percent change) to set user expectations. It is adequate but not exhaustive.

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

Parameters4/5

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

There are no parameters (0 params), so the description adds no parameter-level information. However, schema coverage is 100% (empty schema), and no additional meaning is needed beyond the tool's purpose.

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

Purpose5/5

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

The description clearly specifies the action ('get'), the resource ('top 10 losing stocks'), the exchange ('CSE'), and the time frame ('current trading day'). It effectively distinguishes from sibling tools like 'get_top_gainers' by focusing on losers and specifying the exchange.

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?

No guidance is provided on when to use this tool versus alternatives such as 'get_detailed_company_info' or 'get_top_gainers'. There is no mention of prerequisites, limitations (e.g., only CSE data), or when not to use it.

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/Shaveen12/cse-mcp'

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