MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / verify

Method verify

plugin/bundles/news_api/bundle.py:8–36  ·  view source on GitHub ↗
(self, credentials: BundleCredentials)

Source from the content-addressed store, hash-verified

6
7class NewsApi(BundleHandler):
8 async def verify(self, credentials: BundleCredentials):
9 country: str = "us"
10 category: str = "business"
11 count: int = 10
12
13 news_api_key: str = credentials.credentials.get("NEWS_API_API_KEY")
14
15 url = (
16 f"https://newsapi.org/v2/top-headlines?country={country}&apiKey={news_api_key}&pageSize={count}&page=1"
17 + (f"&category={category}" if category else "")
18 )
19
20 if category is not None and category not in [
21 "business",
22 "entertainment",
23 "general",
24 "health",
25 "science",
26 "sports",
27 "technology",
28 ]:
29 raise_http_error(ErrorCode.REQUEST_VALIDATION_ERROR, "Invalid category")
30
31 async with ClientSession() as session:
32 async with session.get(url=url, proxy=CONFIG.PROXY) as response:
33 if response.status == 200:
34 pass
35 else:
36 raise_credentials_validation_error()

Callers

nothing calls this directly

Calls 3

raise_http_errorFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected