<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Adil Fayyaz on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Adil Fayyaz on Medium]]></description>
        <link>https://medium.com/@fayyaz_19098?source=rss-dac75f6af4d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jNlu5-RiTuzb-fGn_VW9Vw.jpeg</url>
            <title>Stories by Muhammad Adil Fayyaz on Medium</title>
            <link>https://medium.com/@fayyaz_19098?source=rss-dac75f6af4d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:36:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fayyaz_19098/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Slack Logs to Smart Search: Building Local AI with Claude, Python, and MCP]]></title>
            <link>https://medium.com/@fayyaz_19098/from-slack-logs-to-smart-search-building-local-ai-with-claude-python-and-mcp-d3077433189e?source=rss-dac75f6af4d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3077433189e</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[search]]></category>
            <dc:creator><![CDATA[Muhammad Adil Fayyaz]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 06:05:19 GMT</pubDate>
            <atom:updated>2025-04-20T06:29:05.571Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Model Context Protocol (MCP) to build a local Slack conversation assistant powered by Claude Desktop and Python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxj7nRgMQCDYlCE7U1h6ZA.jpeg" /><figcaption>Image Source: <a href="https://slack.com/help/articles/202528808-Search-in-Slack">https://slack.com/help/articles/202528808-Search-in-Slack</a></figcaption></figure><p>Slack has been a backbone of the developer community for a while. It’s where decisions get made, ideas are shared, and brainstorms take shape, but more often than not, they also get buried deep in endless threads and forgotten channels.</p><p>Recently, Slack has started rolling out its own AI-powered search, which is a huge step forward. However, for many developers and teams, especially those working with local data exports or those who want more control and customization, there’s still room to create <strong>lightweight</strong>, <strong>privacy-focused</strong> AI search mechanisms.</p><p>This is where <strong>Agentic Search </strong>comes in.</p><p>By layering <strong>Claude</strong> and the <strong>Model Context Protocol</strong> (MCP) on top of local Slack exports, I built a small but mighty search assistant. Instead of relying solely on keywords, it recalls past conversations buried deep in threads without needing to manually scroll for answers.</p><p>But first, let’s take a step back and understand what MCP really is and why you’ve been hearing more about it lately.</p><h3>What is MCP and Why Should You Care?</h3><p><strong>Model Context Protocol </strong>(MCP) is a standard that lets tools feed structured memory into Claude. Think of it as an HTTP but for AI tools and resources.</p><p>Essentially, you can use MCP to give Claude access to:</p><ul><li>Local Documents and Files</li><li>Custom Indexes</li><li>Databases or Logs</li><li>Real-time APIs</li></ul><p>In my case, I used it to load Slack threads into Claude’s context.</p><blockquote>“MCP is what lets you wire up your Python backend directly into Claude Desktop, so it can ask your server for extra knowledge when answering your questions.”</blockquote><h3><strong>Dataset</strong></h3><p>The Slack chats dataset was downloaded from <a href="https://github.com/preethac/Software-related-Slack-Chats-with-Disentangled-Conversations">https://github.com/preethac/Software-related-Slack-Chats-with-Disentangled-Conversations</a> by Preetha Chatterjee.</p><p><a href="https://github.com/preethac/Software-related-Slack-Chats-with-Disentangled-Conversations">GitHub - preethac/Software-related-Slack-Chats-with-Disentangled-Conversations: A Data Set of Software-related Developer Chat Conversations on Slack</a></p><p>The Slack data is in XML format, with three attributes for each message: timestamp (<em>ts</em>), anonymized user id (<em>user</em>), and message <em>text</em>. The result of disentanglement, which groups utterances into conversations, is provided as the <em>conversation_id</em> attribute of each message.</p><pre> &lt;message conversation_id=&quot;1&quot;&gt;<br>    &lt;ts&gt;2017-06-16T10:51:34.290598&lt;/ts&gt;<br>    &lt;user&gt;Kristie&lt;/user&gt;<br>    &lt;text&gt;Is it possible to switch between conda and virtualenv? That is I want to switch the actual environment managers not just environments in them … I typically use conda but want to try something out that requires virtual env and is not compatible with conda.  Thanks.&lt;/text&gt;<br>  &lt;/message&gt;<br> &lt;message conversation_id=&quot;1&quot;&gt;<br>    &lt;ts&gt;2017-06-16T11:12:26.790435&lt;/ts&gt;<br>    &lt;user&gt;Glory&lt;/user&gt;<br>    &lt;text&gt;i don’t see why you couldn’t use a virtualenv for virtualenv things and conda for conda things. the issue is when you try to mix them together but as long as you’re pointed at the right python interpreter things should work.&lt;/text&gt;<br> &lt;/message&gt;</pre><p>The data is stored in the following directory structure:</p><pre>data<br>+-- clojurians<br>|   +-- 2017<br>|   |   +--- merged-clojurians-clojure.xml<br>|   +-- 2018<br>|   |   +--- merged-clojurians-clojure.xml<br>|   +-- 2019<br>|   |   +--- merged-clojurians-clojure.xml<br>+-- pythondev<br>|   +-- ...<br>+-- elmlang<br>|   +-- ...<br>+-- racket<br>|   +-- ...</pre><h3>Implementation</h3><p>Let’s take a high-level look at the code.</p><p>The detailed code can be found here: <a href="https://github.com/AdilFayyaz/Slack-Search">https://github.com/AdilFayyaz/Slack-Search</a></p><p><strong>Defining Your MCP Server Instance<br></strong>This initializes the FastMCP server with a name, host, port, and timeout settings for handling requests.</p><pre>mcp = FastMCP(<br>    name=&quot;search_slack&quot;,<br>    host=&quot;127.0.0.1&quot;,<br>    port=5000,<br>    timeout=20<br>)</pre><p><strong>Defining Your MCP Tools<br></strong>These are MCP tools: <strong><em>search_slack</em></strong> searches for relevant Slack conversations based on a query, while <strong><em>summarize_conversations </em></strong>provides a summary of the top retrieved conversations.</p><pre>@mcp.tool()<br>def search_slack(query: str, community: str = None, year: str = None, top_n: int = 5):<br>    &quot;&quot;&quot;Search Slack conversations based on a query&quot;&quot;&quot;<br>    filtered_docs = docs<br>    filtered_meta = meta<br>    .......<br><br>    matrix = tfidf_matrix if not (community or year) else vectorizer.transform(filtered_docs)<br>    query_vec = vectorizer.transform([query])<br>    similarities = cosine_similarity(query_vec, matrix).flatten()<br>    top_indices = similarities.argsort()[-top_n:][::-1]<br><br>    .......<br>    return results<br><br>@mcp.tool()<br>def summarize_conversations(conversations: list) -&gt; str:<br>    &quot;&quot;&quot;Summarize retrieved conversations&quot;&quot;&quot;<br>    summary = &quot;\n&quot;.join([<br>        f&quot;Community: {conv[&#39;metadata&#39;][&#39;community&#39;]}, Year: {conv[&#39;metadata&#39;][&#39;year&#39;]}\n{conv[&#39;content&#39;][:300]}...&quot;<br>        for conv in conversations<br>    ])<br>    return f&quot;Summary of top conversations:\n{summary}&quot;</pre><p><strong>Defining Your <em>claude_desktop_config.json</em> File<br></strong>This configuration defines the MCP server settings, including the command to run the server, the environment setup, and the host, port, and timeout values for communication.</p><pre>{<br>    &quot;mcpServers&quot;: {<br>      &quot;search_slack&quot;: {<br>        &quot;command&quot;: &quot;/bin/zsh&quot;,<br>      &quot;args&quot;: [<br>        &quot;-c&quot;,<br>        &quot;source /.venv/bin/activate &amp;&amp; python3 /Users/.../mcp_server.py&quot;<br>      ],<br>        &quot;host&quot;: &quot;127.0.0.1&quot;,<br>        &quot;port&quot;: 5000,<br>        &quot;timeout&quot;: 10000<br>      }<br>    }<br>  }</pre><h3><strong>Testing with Claude</strong></h3><p>Fire up Claude Desktop, prompt it with something like:</p><blockquote>“List threads that talk about roadmaps or planning.”</blockquote><p>Claude automatically triggers the <strong><em>search_slack</em></strong> tool, gets results, and then optionally calls the <strong><em>summarize_conversations</em></strong> tool to give you a clean summary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz6GchCmxKzpjUTYilJ5dg.png" /></figure><p>In the image below, notice how Claude first uses the tool to define the <strong><em>query</em></strong> and <strong><em>top_n</em></strong> context before searching with the locally defined <strong><em>search_slack</em></strong> tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3T7ieoCjtIN4_Jxrwa2ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bVB_mf7zS8fiAhSq2F5aGg.png" /></figure><h3>What’s Next?</h3><p>This is just scratching the surface. With MCP and agentic AI workflows, you can:</p><ul><li>Search local PDFs and emails</li><li>Index codebases or commit logs</li><li>Chat with private documentation</li><li>Build memory-aware assistants</li></ul><h3>Final Thoughts</h3><p>There are so many cool applications you can build with MCP and agentic AI; this is just the beginning. This project simply showcases how easy it can be to stitch together a local application using Claude, Python, and a bit of motivation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3077433189e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling Financial Performance: Analyzing Earnings Calls and CEO Public Appearances with…]]></title>
            <link>https://medium.com/@fayyaz_19098/unveiling-financial-performance-analyzing-earnings-calls-and-ceo-public-appearances-with-71f9f9db1695?source=rss-dac75f6af4d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/71f9f9db1695</guid>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[ceo]]></category>
            <category><![CDATA[earnings]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Muhammad Adil Fayyaz]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 17:50:12 GMT</pubDate>
            <atom:updated>2024-08-12T17:50:12.365Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Unveiling Financial Performance: Analyzing Earnings Calls and CEO Public Appearances with Retrieval-Augmented Generation</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFczKVsBJmdfckVj11iQnA.jpeg" /></figure><p>In the fast-paced world of finance, the words spoken by a CEO and the content of earnings calls can significantly influence investor sentiment and market movements. But how exactly do these public communications impact a company’s financial performance? In this article, we delve into an analysis that explores the correlation between earnings call sentiment, CEO public appearances, and financial metrics such as stock prices and earnings per share (EPS).</p><h3><strong>The Power of Corporate Communication</strong></h3><h4><strong><em>The Role of Earnings Call</em></strong></h4><p>Earnings calls are a crucial aspect of corporate communication, providing a platform for companies to disclose their financial performance, future outlook, and strategic initiatives. These calls offer investors a glimpse into the company’s current standing and potential trajectory, making them vital for informed investment decisions.</p><h4><strong><em>CEO Public Appearances: More Than Just Words</em></strong></h4><p>CEOs are often seen as the face of the company, and their public appearances — whether in interviews, speeches, or conferences — can have a profound impact on market perception. The confidence or caution in a CEO’s tone, the words they choose, and even their body language can sway investor sentiment and, consequently, the stock price.</p><h3><strong>Methodology</strong></h3><h4><strong>Gathering the Data</strong></h4><p>For this analysis, I have utilized a comprehensive dataset comprising earnings call transcripts and records of CEO public appearances. The data on EPS and stock prices was sourced from different financial databases.</p><h4>Data Preparation and Preprocessing</h4><ul><li><strong>Loading and Cleaning Data</strong>: Earnings call data and CEO public appearance transcripts are loaded from CSV files and preprocessed to ensure consistency and accuracy.</li><li><strong>Text Preprocessing</strong>: Text data from transcripts is cleaned to remove stop words and other irrelevant elements, and is then tokenized to prepare for further analysis.</li></ul><pre>nltk.download(&#39;stopwords&#39;)<br><br># Initialize the stop words list<br>stop_words = set(stopwords.words(&#39;english&#39;))<br><br>def preprocess_text(text):<br>    # Tokenize the text<br>    tokens = text.split()<br>    # Remove stop words<br>    tokens = [word for word in tokens if word not in stop_words]<br>    # Join tokens back into a single string<br>    cleaned_text = &#39; &#39;.join(tokens)<br>    return cleaned_text</pre><h4>Retrieval-Augmented Generation (RAG) Pipeline</h4><ul><li><strong>Transcript Loading and Processing</strong>: Earnings call transcripts are loaded, sorted, and preprocessed. These transcripts are then converted into a dictionary format for easy access and querying.</li></ul><pre>def read_files(directory):<br>    transcripts = {}<br><br>    # List all files in the directory<br>    for filename in os.listdir(directory):<br>        if &quot;Apple&quot; in filename:  # Filter files containing &#39;Apple&#39; in their name<br>            file_path = os.path.join(directory, filename)<br>            with open(file_path, &#39;r&#39;) as file:<br>                lines = file.readlines()<br>                if lines:<br>                    date = extract_date(lines[0].strip())   # Extract date from the first line<br>                    transcript = &#39;&#39;.join(lines[1:])  # Get the rest of the transcript<br>                    cleaned_transcript = preprocess_text(transcript)  # Preprocess the transcript<br>                    transcripts[date] = cleaned_transcript<br><br>    return transcripts</pre><ul><li><strong>Prompt Template Definition</strong>: A prompt template is defined for querying the language model, focusing on extracting relevant information from the transcripts to answer specific questions.</li></ul><pre>PROMPT_TEMPLATE = &quot;&quot;&quot;<br>You are provided with a set of earnings call transcripts. Answer the following question using only the provided context:<br><br>Context: {context}<br><br>Specify your response in the format &#39;date: source text&#39;.<br>Ensure that you refer to the transcripts between the earnings calls for each date mentioned in the context.<br><br>Your response should include at least 10 examples, if available. Do not repeat the responses.<br><br>Example Response Format:<br>2023-04-25: &quot;The CEO mentioned that the revenue growth was lower than expected, impacting the stock price negatively.&quot;<br>&quot;&quot;&quot;</pre><ul><li><strong>Retrieving Relevant Transcripts</strong>: The pipeline retrieves transcripts that fall within the relevant date ranges around each earnings call, generating a context for the language model to produce responses.</li></ul><pre>if prev_date &lt;= transcript_date &lt;= earnings_call_date:<br>  content_tokens = len(tokenizer.tokenize(content))<br>  # Search the DB<br>  CHROMA_PATH = &quot;/tmp/chroma/&quot; + str(transcript_date.date())<br>  db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embedding_function)<br>  results.append(db.similarity_search_with_relevance_scores(query_text, k=3))<br>  if token_count + content_tokens &gt; max_tokens:<br>      break<br>  context.append(f&quot;Date: {d}\n{content}&quot;)<br>  token_count += content_tokens</pre><ul><li><strong>Generating Responses</strong>: Using a language model, responses are generated based on the provided context and prompt, capturing insights from the transcripts.</li></ul><h4>Filtering and Embedding Analysis</h4><ul><li><strong>Filtering Valid Responses</strong>: Responses are filtered to exclude those with empty or irrelevant sources, focusing on meaningful data.</li></ul><pre>import ast<br>valid_responses = []<br>for response in responses:<br>    src = response.split(&quot;\nSources:&quot;)<br>    src = ast.literal_eval(src[1])<br>    if all(item == &#39;&#39; for item in src): # check to see if all sources are empty or not<br>      continue<br>    date = response.split(&quot;Response for date &quot;)[1].split(&quot;:&quot;)[0]<br>    res = response.split(&quot;Response for date &quot;+ date + &quot;:&quot;)[1].strip()<br>    valid_responses.append((date, res))</pre><ul><li><strong>BERT Embeddings</strong>: The filtered responses are transformed into BERT embeddings to represent the semantic content of the text.</li></ul><pre>from transformers import BertTokenizer, BertModel<br>import torch<br><br># Load pre-trained model tokenizer<br>tokenizer = BertTokenizer.from_pretrained(&#39;bert-base-uncased&#39;)<br>model = BertModel.from_pretrained(&#39;bert-base-uncased&#39;)<br><br># Function to generate embeddings<br>def get_bert_embeddings(texts):<br>    embeddings = []<br>    with torch.no_grad():<br>        for text in texts:<br>            # Tokenize input text and convert to tensor<br>            inputs = tokenizer(text, return_tensors=&#39;pt&#39;, truncation=True, padding=True)<br><br>            # Get BERT output<br>            outputs = model(**inputs)<br><br>            # We take the embeddings from the last hidden layer<br>            # Use the mean of the token embeddings as the sentence embedding<br>            last_hidden_states = outputs.last_hidden_state<br>            sentence_embedding = last_hidden_states.mean(dim=1)<br><br>            embeddings.append(sentence_embedding.squeeze().numpy())<br><br>    return embeddings</pre><ul><li><strong>Embedding and Data Distribution Comparison</strong>: BERT embeddings are transformed into their mean distribution across all embeddings and then compared with the distribution of scaled financial data to assess how well they capture the data’s characteristics.</li></ul><h4>Distribution Comparison and KL Divergence</h4><ul><li><strong>Histogram Calculation</strong>: A histogram is computed for both the embeddings and the scaled financial data, normalizing the distributions to facilitate comparison.</li></ul><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br># Plot histograms<br>plt.figure(figsize=(14, 7))<br>plt.hist(embedding_bins[:-1], embedding_bins, weights=embedding_distribution, alpha=0.5, label=&#39;Embedding Distribution&#39;)<br>plt.hist(data_bins[:-1], data_bins, weights=data_distribution, alpha=0.5, label=&#39;Scaled Data Distribution&#39;)<br>plt.legend(loc=&#39;upper right&#39;)<br>plt.xlabel(&#39;Value&#39;)<br>plt.ylabel(&#39;Density&#39;)<br>plt.title(&#39;Histogram of Embedding Distribution vs. Scaled Data Distribution&#39;)<br>plt.show()</pre><ul><li><strong>KL Divergence</strong>: The Kullback-Leibler (KL) divergence is calculated to quantify the difference between the embedding distribution and the scaled data distribution. This measure helps evaluate the effectiveness of the embeddings in representing the financial data’s statistical properties. (KL Divergence: 4.237)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhB0f9VLj2XUOChRfRiApg.png" /></figure><h3>Results and Insights</h3><ul><li>The histogram shows a good visual correlation between the BERT embeddings of the CEO’s public communications and the scaled financial data. The significant overlap in the central region of the distributions suggests that the text data from the CEO’s communications is reflective of or correlated with the financial performance captured in the scaled data.</li><li>If the textual data can reliably predict or reflect financial data trends, this correlation could be used to forecast financial performance based on the CEO’s public statements, providing valuable insights for decision-makers and analysts.</li></ul><p>The complete source code can be found at: <a href="https://github.com/AdilFayyaz/Earnings-Call-and-CEO-Public-Appearances-Correlation-Analysis">https://github.com/AdilFayyaz/Earnings-Call-and-CEO-Public-Appearances-Correlation-Analysis</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71f9f9db1695" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>