Skip to main content
Glama

FirstCycling MCP Server

by r-huijts
MIT License
14
  • Apple
endpoints.py1.38 kB
""" Endpoints ========= Provides classes for API objects. """ import bs4 import json import pandas as pd import datetime class Endpoint: """ Generalized class to store endpoint responses. Attributes ---------- response : bytes Raw response from firstcycling.com """ def __init__(self, response): self.response = response """ Raw response from firstcycling.com. """ def _to_json(self): return vars(self).copy() def get_json(self): """ Get JSON representation of endpoint response. """ return json.dumps(self, default=ComplexHandler) class ParsedEndpoint(Endpoint): def __init__(self, response): super().__init__(response) self._parse_result() def _parse_result(self): self.soup = bs4.BeautifulSoup(self.response, 'html.parser') self._parse_soup() def _parse_soup(self): return def ComplexHandler(obj): """ Customized handler to convert object to JSON by recursively calling to_json() method. Adapted from https://stackoverflow.com/questions/5160077/encoding-nested-python-object-in-json """ if hasattr(obj, '_to_json'): return obj._to_json() elif isinstance(obj, datetime.date): return str(obj) elif isinstance(obj, pd.DataFrame): return obj.to_json() elif isinstance(obj, bytes): return obj.decode("utf-8") else: raise TypeError('Object of type %s with value of %s is not JSON serializable' % (type(obj), repr(obj)))

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/r-huijts/firstcycling-mcp'

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