Skip to main content
Glama
Shaveen12

CSE MCP Server

by Shaveen12

Get Detailed Company Info

get_detailed_company_info

Retrieve comprehensive company data from the Colombo Stock Exchange, including 52-week high/low, YTD metrics, market cap, and beta values, by providing the ticker symbol obtained from the search tool.

Instructions

Get comprehensive company information including 52-week high/low, YTD metrics, market cap, and beta values. Use search_company first to find the correct symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTicker symbol from CSE (e.g., 'JKH.N0000')

Implementation Reference

  • Core handler function that fetches detailed company info from the CSE API (companyInfoSummery endpoint). Looks up the company by symbol from the loaded CSV, makes an HTTP POST request, and returns comprehensive data including 52-week high/low, YTD metrics, market cap, shares issued, and beta value.
    async function getDetailedCompanyInfo(symbol: string) {
      const company = companies.find(c => c.symbol === symbol);
      
      if (!company) {
        throw new Error(`Symbol ${symbol} not found. Please use search_company to find valid symbols.`);
      }
      
      try {
        const response = await axios.post(
          'https://www.cse.lk/api/companyInfoSummery',
          `symbol=${symbol}`,
          {
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            },
            timeout: 10000
          }
        );
        
        const data = response.data;
        const symbolInfo = data.reqSymbolInfo || {};
        const betaInfo = data.reqSymbolBetaInfo || {};
        
        return {
          symbol: symbolInfo.symbol,
          companyName: symbolInfo.name,
          lastTradedPrice: symbolInfo.lastTradedPrice,
          price52WeekHigh: symbolInfo.p12HiPrice,
          price52WeekLow: symbolInfo.p12LowPrice,
          ytdShareVolume: symbolInfo.ytdShareVolume,
          ytdTurnover: symbolInfo.ytdTurnover,
          marketCap: symbolInfo.marketCap,
          sharesIssued: symbolInfo.sharesIssued,
          beta: betaInfo.beta,
          lastUpdated: new Date().toISOString()
        };
      } 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}`);
        }
      }
    }
  • Input schema validation for get_detailed_company_info, using Zod to validate the 'symbol' parameter with a regex pattern for CSE ticker format (e.g., 'JKH.N0000').
    inputSchema: {
      symbol: z.string()
        .regex(/^[A-Z]+\.[A-Z0-9]+$/, "Invalid symbol format. Use format like 'JKH.N0000'")
        .describe("Ticker symbol from CSE (e.g., 'JKH.N0000')")
    }
  • src/index.ts:419-462 (registration)
    Registration of the 'get_detailed_company_info' tool on the MCP server with its title, description, input schema, and the handler callback that invokes getDetailedCompanyInfo and formats the response.
    server.registerTool(
      "get_detailed_company_info",
      {
        title: "Get Detailed Company Info",
        description: "Get comprehensive company information including 52-week high/low, YTD metrics, market cap, and beta values. Use search_company first to find the correct symbol.",
        inputSchema: {
          symbol: z.string()
            .regex(/^[A-Z]+\.[A-Z0-9]+$/, "Invalid symbol format. Use format like 'JKH.N0000'")
            .describe("Ticker symbol from CSE (e.g., 'JKH.N0000')")
        }
      },
      async ({ symbol }) => {
        try {
          const detailedInfo = await getDetailedCompanyInfo(symbol);
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                symbol: detailedInfo.symbol,
                companyName: detailedInfo.companyName,
                lastTradedPrice: detailedInfo.lastTradedPrice ? `Rs. ${detailedInfo.lastTradedPrice.toFixed(2)}` : 'N/A',
                price52WeekHigh: detailedInfo.price52WeekHigh ? `Rs. ${detailedInfo.price52WeekHigh.toFixed(2)}` : 'N/A',
                price52WeekLow: detailedInfo.price52WeekLow ? `Rs. ${detailedInfo.price52WeekLow.toFixed(2)}` : 'N/A',
                ytdShareVolume: detailedInfo.ytdShareVolume?.toLocaleString() || 'N/A',
                ytdTurnover: detailedInfo.ytdTurnover ? `Rs. ${detailedInfo.ytdTurnover.toLocaleString()}` : 'N/A',
                marketCap: detailedInfo.marketCap ? `Rs. ${detailedInfo.marketCap.toLocaleString()}` : 'N/A',
                sharesIssued: detailedInfo.sharesIssued?.toLocaleString() || 'N/A',
                beta: detailedInfo.beta || 'N/A',
                lastUpdated: detailedInfo.lastUpdated
              }, null, 2)
            }]
          };
        } catch (error: any) {
          return {
            content: [{
              type: "text",
              text: `Error fetching detailed company info: ${error.message}`
            }],
            isError: true
          };
        }
      }
    );
Behavior3/5

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

No annotations are provided, so the description carries the burden. It lists the returned data types but does not disclose potential behaviors like error handling, data freshness, or query limits. The description is adequate but not comprehensive.

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?

Two concise sentences: the first states the purpose with examples, the second gives usage guidance. No redundant information, and the content is front-loaded.

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?

The description covers the tool's purpose, prerequisite, and example outputs. While it omits details like authentication or real-time vs. delayed data, it is sufficient given the simplicity of the tool and absence of output schema.

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?

Schema coverage is 100% with a description for the symbol parameter. The description adds a concrete example ('JKH.N0000') and suggests using search_company first, which adds meaning beyond the schema pattern alone.

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 states it retrieves comprehensive company info and lists specific metrics (52-week high/low, YTD metrics, market cap, beta). It distinguishes from siblings like search_company by explicitly stating a prerequisite.

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

Usage Guidelines4/5

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

Provides explicit guidance to use search_company first to find the correct symbol, which clarifies when this tool is appropriate. However, it does not mention when to avoid this tool in favor of other siblings like get_stock_data.

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