Skip to main content
Glama

Remote MCP with Azure Functions

MIT License
function_app.cpython-310.pyc3.98 kB
o q�xh�@s^ddlZddlZddlmZejejjd�ZdZ dZ de dZ Gdd�d�Z e e d d �e e d d �gZ e e d d �gZe�d d �e D��Ze�dd �eD��Zejdddddd�d%dd��Zejdddded�ejddde d�dejdefdd���Zejdddded�ejddde d�dejedefd d���Zejd!ejjd"�d#ejdejfd$d!��ZdS)&�N)�http_auth_levelZ snippetnameZsnippetzsnippets/{mcptoolargs.z}.jsonc@s*eZdZdededefdd�Zdd�ZdS) � ToolProperty� property_name� property_type� descriptioncCs||_||_||_dS)N�Z propertyNameZ propertyTyper)�selfrrr�r �S/Users/pravinkumar/Documents/GitHub/remote-mcp-functions-python/src/function_app.py�__init__s zToolProperty.__init__cCs|j|j|jd�S)Nrr)rr r r �to_dicts�zToolProperty.to_dictN)�__name__� __module__� __qualname__�strr r r r r r rs r�stringzThe name of the snippet.zThe content of the snippet.cC�g|]}|���qSr �r ��.0�propr r r � <listcomp>%�rcCrr rrr r r r&r�contextZmcpToolTrigger� hello_mcpz Hello world.z[])�arg_name�typeZtoolNamerZtoolProperties�returncCsdS)z� A simple function that returns a greeting message. Args: context: The trigger context (not used in this function). Returns: str: A greeting message. zHello I am MCPTool!r )rr r r r)s� get_snippetzRetrieve a snippet by name.�file�blob�AzureWebJobsStorage)rr� connection�pathcCs"|���d�}t�d|���|S)a9 Retrieves a snippet by name from Azure Blob Storage. Args: file (func.InputStream): The input binding to read the snippet from Azure Blob Storage. context: The trigger context containing the input arguments. Returns: str: The content of the snippet or an error message. zutf-8zRetrieved snippet: )�read�decode�logging�info)rrZsnippet_contentr r r r=s� save_snippetzSave a snippet with a name.cCsXt�|�}|dt}|dt}|sdS|sdS|�|�t�d|���d|�d�S)N� argumentszNo snippet name providedzNo snippet content providedzSaved snippet: z Snippet 'z' saved successfully)�json�loads�_SNIPPET_NAME_PROPERTY_NAME�_SNIPPET_PROPERTY_NAME�setr&r')rr�contentZsnippet_name_from_argsZsnippet_content_from_argsr r r r(Us    � HelloFunction)�route� auth_level�reqcCsht�d�|j�d�}|s"z|��}Wn tyYnw|�d�}|r-t�d|�d��Stjddd�S)Nz1Python HTTP trigger function processed a request.�namezHello, z5. This HTTP triggered function executed successfully.z�This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.��)� status_code)r&r'�params�get�get_json� ValueError�func� HttpResponse)r3r4Zreq_bodyr r r r0ms    � �)rN) r*r&�azure.functions� functionsr;� FunctionApp� AuthLevel�FUNCTION�appr,r-Z _BLOB_PATHrZ$tool_properties_save_snippets_objectZ#tool_properties_get_snippets_object�dumpsZ"tool_properties_save_snippets_jsonZ!tool_properties_get_snippets_json�generic_triggerr�generic_input_binding� InputStreamrr�generic_output_binding�Outr(r1� ANONYMOUS� HttpRequestr<r0r r r r �<module>sT    ��  ��

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/pravin22kumar/MCP'

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