Skip to main content
Glama
tandat8503

Rentcast MCP Server

by tandat8503

analyze_market

Generate market statistics and trends for real estate by location, providing rental and sales data analysis to inform property decisions.

Instructions

Get comprehensive market statistics and trends for specific locations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityNoCity name for market analysis
dataTypeNoType of market data to analyzeAll
stateNoState abbreviation for market analysis
zipCodeNoZIP code for market analysis

Implementation Reference

  • The main execution handler for the 'analyze_market' tool. It constructs parameters, calls the Rentcast API's getMarketData method, processes the response, formats sale and rental market data using helper functions, and returns a formatted text response.
    server.tool(
      "analyze_market",
      "Get comprehensive market statistics and trends for specific locations",
      MarketAnalysisSchema.shape,
      async (params) => {
        try {
          const searchParams: any = { dataType: params.dataType };
          if (params.zipCode) searchParams.zipCode = params.zipCode;
          if (params.city) searchParams.city = params.city;
          if (params.state) searchParams.state = params.state;
    
                const result = await rentcastAPI.getMarketData(searchParams);
    
          if (!result.success) {
            return createErrorResponse("Error analyzing market", result.error);
          }
    
          // Simplified market data handling - focus on the structure we know API returns
          const market = Array.isArray(result.data) ? result.data[0] : result.data;
          
    
    
            if (!market || (!market.saleData && !market.rentalData)) {
              return createErrorResponse("No market data found for the specified location");
            }
            
            let resultText = `šŸ“Š Market Statistics for ${market.zipCode ? `ZIP: ${market.zipCode}` : (params.city ? `${params.city}, ${params.state}` : 'Location')}\n`;
            
            // Add location info
            if (market.zipCode) {
              resultText += `\nšŸ“ Location: ZIP ${market.zipCode}`;
            }
            if (market.city && market.state) {
              resultText += `\nšŸ™ļø ${market.city}, ${market.state}`;
            }
            
            // Format market data
            if (market.saleData) {
              resultText += formatSaleMarketData(market.saleData);
            }
            
            if (market.rentalData) {
              resultText += formatRentalMarketData(market.rentalData);
            }
            
            return createSuccessResponse(resultText);
    
              } catch (error) {
            return createErrorResponse("Failed to analyze market", error instanceof Error ? error.message : 'Unknown error');
          }
      }
    );
  • Zod schema defining the input parameters for the 'analyze_market' tool, including optional location fields and data type.
    export const MarketAnalysisSchema = z.object({
      zipCode: z.string().optional().describe("ZIP code for market analysis"),
      city: z.string().optional().describe("City name for market analysis"),
      state: z
        .string()
        .optional()
        .describe("State abbreviation for market analysis"),
      dataType: z
        .enum(["All", "Sale", "Rental"])
        .default("All")
        .describe("Type of market data to analyze"),
    });
  • Helper function to format sale market data (average/median prices, listings, etc.) for the analyze_market tool response.
    function formatSaleMarketData(saleData: any): string {
      if (!saleData) return '';
      
      let result = `\nSales Market:`;
      
      // Current month data
      if (saleData.averagePrice !== undefined) {
        result += `\nAverage Price: $${Number(saleData.averagePrice).toLocaleString()}`;
      }
      if (saleData.medianPrice !== undefined) {
        result += `\nšŸ“ˆ Median Price: $${Number(saleData.medianPrice).toLocaleString()}`;
      }
      if (saleData.averagePricePerSquareFoot !== undefined) {
        result += `\nšŸ“ Avg Price/Sqft: $${Number(saleData.averagePricePerSquareFoot).toFixed(2)}`;
      }
      if (saleData.averageDaysOnMarket !== undefined) {
        result += `\nAvg Days on Market: ${Number(saleData.averageDaysOnMarket).toFixed(1)}`;
      }
      if (saleData.newListings !== undefined) {
        result += `\nšŸ†• New Listings: ${saleData.newListings}`;
      }
      if (saleData.totalListings !== undefined) {
        result += `\nšŸ“‹ Total Listings: ${saleData.totalListings}`;
      }
      
      // Property type breakdown
      if (saleData.dataByPropertyType && saleData.dataByPropertyType.length > 0) {
        result += `\n\nšŸ  By Property Type:`;
        saleData.dataByPropertyType.slice(0, 3).forEach((typeData: any) => {
          const avgPrice = typeData.averagePrice ? `$${Number(typeData.averagePrice).toLocaleString()}` : 'N/A';
          result += `\n• ${typeData.propertyType}: ${avgPrice} avg`;
        });
      }
      
      return result;
    }
  • Helper function to format rental market data (average/median rents, listings, etc.) for the analyze_market tool response.
    function formatRentalMarketData(rentalData: any): string {
      if (!rentalData) return '';
      
      let result = `\n\nšŸ˜ļø Rental Market:`;
      
      // Current month data
      if (rentalData.averageRent !== undefined) {
        result += `\nšŸ’° Average Rent: $${Number(rentalData.averageRent).toLocaleString()}/month`;
      }
      if (rentalData.medianRent !== undefined) {
        result += `\nšŸ“ˆ Median Rent: $${Number(rentalData.medianRent).toLocaleString()}/month`;
      }
      if (rentalData.averageRentPerSquareFoot !== undefined) {
        result += `\nšŸ“ Avg Rent/Sqft: $${Number(rentalData.averageRentPerSquareFoot).toFixed(2)}`;
      }
      if (rentalData.newListings !== undefined) {
        result += `\nšŸ†• New Listings: ${rentalData.newListings}`;
      }
      if (rentalData.totalListings !== undefined) {
        result += `\nšŸ“‹ Total Listings: ${rentalData.totalListings}`;
      }
      
      // Property type breakdown
      if (rentalData.dataByPropertyType && rentalData.dataByPropertyType.length > 0) {
        result += `\n\nšŸ  By Property Type:`;
        rentalData.dataByPropertyType.slice(0, 3).forEach((typeData: any) => {
          const avgRent = typeData.averageRent ? `$${Number(typeData.averageRent).toLocaleString()}/month` : 'N/A';
          result += `\n• ${typeData.propertyType}: ${avgRent} avg`;
        });
      }
      
      return result;
  • Service method in RentcastAPI that performs the actual API call to /markets endpoint, used by the analyze_market handler.
    async getMarketData(
      params: {
        zipCode?: string;
        city?: string;
        state?: string;
        dataType?: string;
      } = {},
    ): Promise<ApiCallResult> {
      const result = await this.makeRequest<RentcastMarket[]>("/markets", {
        ...params,
        dataType: params.dataType || "All",
      });
      return result;
    }
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. It implies a read-only operation ('Get') but doesn't specify permissions, rate limits, data freshness, or what 'comprehensive' entails (e.g., time range, metrics included). This is inadequate for a tool that likely involves complex data retrieval.

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, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence contributes meaning, making it appropriately sized and well-structured.

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?

Given the tool's complexity (market analysis with multiple parameters) and lack of annotations and output schema, the description is insufficient. It doesn't explain what 'comprehensive market statistics and trends' includes, potential limitations, or response format, leaving significant gaps for the agent.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond implying location-based filtering, which is already clear from the schema. This meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Get') and resource ('comprehensive market statistics and trends'), and specifies the scope ('for specific locations'). However, it doesn't explicitly differentiate from sibling tools like 'get_rent_estimates' or 'search_properties' that might also provide market-related data, which prevents a perfect score.

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 on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or compare to sibling tools such as 'get_rent_estimates' or 'get_sale_listings', leaving the agent with no context for 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/tandat8503/mcp_rentcast'

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