gperdrizet commited on
Commit
8863982
·
unverified ·
1 Parent(s): 30f55ec

Feed finder function done.

Browse files
assets/html.py CHANGED
@@ -3,9 +3,9 @@
3
  TITLE = (
4
  '''
5
  <center>
6
- <h1>Letter counter</h1>
7
  </center>
8
  '''
9
  )
10
 
11
- DESCRIPTION = 'Enter text and a letter to count how many times the letter appears in the text.'
 
3
  TITLE = (
4
  '''
5
  <center>
6
+ <h1>RSS feed finder</h1>
7
  </center>
8
  '''
9
  )
10
 
11
+ DESCRIPTION = 'Enter a website to crawl for RSS feed URI.'
functions/helper_functions.py ADDED
@@ -0,0 +1 @@
 
 
1
+ '''Helper functions for MCP tools.'''
functions/tools.py CHANGED
@@ -1,18 +1,22 @@
1
  '''Tool functions for MCP server'''
2
 
 
3
 
4
- def letter_counter(word, letter):
5
- """
6
- Count the number of occurrences of a letter in a word or text.
7
 
 
 
 
8
  Args:
9
- word (str): The input text to search through
10
- letter (str): The letter to search for
11
-
12
  Returns:
13
- str: A message indicating how many times the letter appears
14
- """
15
- word = word.lower()
16
- letter = letter.lower()
17
- count = word.count(letter)
18
- return count
 
 
 
 
 
1
  '''Tool functions for MCP server'''
2
 
3
+ from findfeed import search
4
 
 
 
 
5
 
6
+ def get_feed(url: str) -> str:
7
+ '''Finds the RSS feed URI for a website given the website's url.
8
+
9
  Args:
10
+ url: The url for the website to find the RSS feed for
11
+
 
12
  Returns:
13
+ The website's RSS feed URI as a string
14
+ '''
15
+
16
+ feeds = search(url)
17
+
18
+ if len(feeds) > 0:
19
+ return str(feeds[0].url)
20
+
21
+ else:
22
+ return f'No feed found for {url}'
rss_server.py CHANGED
@@ -11,16 +11,15 @@ with gr.Blocks() as demo:
11
  gr.HTML(html.TITLE)
12
 
13
  gr.Markdown(html.DESCRIPTION)
14
- input_word = gr.Textbox('strawberry', label='Text')
15
- target_letter = gr.Textbox('r', label='Word')
16
- output = gr.Number(label='Letter count')
17
- count_button = gr.Button('Count')
18
-
19
- count_button.click( # pylint: disable=no-member
20
- fn=tool_funcs.letter_counter,
21
- inputs=[input_word, target_letter],
22
  outputs=output,
23
- api_name='letter count'
24
  )
25
 
26
 
 
11
  gr.HTML(html.TITLE)
12
 
13
  gr.Markdown(html.DESCRIPTION)
14
+ website_url = gr.Textbox('hackernews.com', label='Website URL')
15
+ output = gr.Textbox(label='RSS feed URI')
16
+ submit_button = gr.Button('Submit')
17
+
18
+ submit_button.click( # pylint: disable=no-member
19
+ fn=tool_funcs.get_feed,
20
+ inputs=website_url,
 
21
  outputs=output,
22
+ api_name='get_feed'
23
  )
24
 
25