MCP-Server-for-Excel-Integration

AyushRatan1/MCP-Server-for-Excel-Integration

3.1

If you are the rightful owner of MCP-Server-for-Excel-Integration and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A simple MCP server built with FastAPI that processes numerical inputs by doubling them, with support for session management and API key authentication.

The Model Context Protocol (MCP) Server is a lightweight server application designed to process numerical inputs by doubling each value. Built using FastAPI, it supports session management and API key authentication to ensure secure and stateful interactions. The server is easy to set up and run, making it suitable for quick deployments and testing. It provides a single API endpoint for processing data, and it can be integrated with various platforms, including Excel, for seamless data processing workflows. The server is designed to handle cross-origin requests, making it accessible from web-based clients.

Features

  • FastAPI-based server for quick and efficient processing
  • Session management to maintain state between requests
  • API key authentication for secure access
  • CORS support for cross-origin requests
  • Simple setup and deployment process

Usages

usage with excel vba

vb
Sub CallMCPServer()
    ' Define the input range
    Dim inputRange As Range
    Set inputRange = Range("A1:A3")
    
    ' Create an HTTP request
    Dim request As Object
    Set request = CreateObject("MSXML2.XMLHTTP")
    
    ' Prepare JSON data
    Dim jsonData As String
    jsonData = "{""inputs"": ["
    
    Dim cell As Range
    Dim first As Boolean
    first = True
    
    For Each cell In inputRange
        If Not first Then
            jsonData = jsonData & ", "
        End If
        jsonData = jsonData & cell.Value
        first = False
    Next cell
    
    jsonData = jsonData & "]}"
    
    ' Send the request
    request.Open "POST", "http://localhost:8000/mcp/process", False
    request.setRequestHeader "Content-Type", "application/json"
    request.send jsonData
    
    ' Handle the response
    If request.Status = 200 Then
        Dim response As Object
        Set response = ParseJson(request.responseText)
        
        ' Display the outputs
        Dim outputStr As String
        outputStr = "Processed outputs: " & vbCrLf
        
        Dim i As Integer
        For i = 1 To response.Item("outputs").Count
            outputStr = outputStr & response.Item("outputs").Item(i) & vbCrLf
        Next i
        
        MsgBox outputStr, vbInformation, "MCP Server Response"
        
        ' Optionally store the session ID for future requests
        Dim sessionId As String
        sessionId = response.Item("session_id")
    Else
        MsgBox "Error: " & request.Status & " - " & request.responseText, vbExclamation
    End If
End Sub

Function ParseJson(jsonString As String) As Object
    ' This is a simplified JSON parser for demo purposes
    ' For production use, consider a proper JSON library
    Dim ScriptEngine As Object
    Set ScriptEngine = CreateObject("ScriptControl")
    ScriptEngine.Language = "JScript"
    
    Dim JsonCode As String
    JsonCode = "JSON.parse('" & Replace(jsonString, "'", "\'") & "');"
    
    Set ParseJson = ScriptEngine.Eval(JsonCode)
End Function