Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implementation of the first version #2

Merged
merged 33 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf27f11
Initial import
jirispilka Jan 27, 2025
45cfdc9
Cleanup code
jirispilka Jan 27, 2025
1cad71d
Working example
jirispilka Jan 27, 2025
e537a68
Improve message handling
jirispilka Jan 27, 2025
c681a92
Lint fix
jirispilka Jan 27, 2025
2d62826
Working solution with SSE
jirispilka Jan 28, 2025
6fe89f8
Process messages
jirispilka Jan 28, 2025
ae3f244
Add README.md
jirispilka Jan 28, 2025
c1b7476
Fix input schema
jirispilka Jan 28, 2025
e2034ac
Merge pull request #1 from apify/detached
jirispilka Jan 28, 2025
16406ce
Update const.ts and input_schema.json
jirispilka Jan 28, 2025
7d1c295
Merge remote-tracking branch 'origin/feat/implementation' into feat/i…
jirispilka Jan 28, 2025
a58ccb9
Add Dockerfile
jirispilka Jan 28, 2025
063c485
Update README.md
jirispilka Jan 28, 2025
18425bc
Update README.md
jirispilka Jan 28, 2025
edeb6cd
Update README.md
jirispilka Jan 29, 2025
c4741df
Update Dockerfile
jirispilka Jan 29, 2025
25f1cdf
Add const
jirispilka Jan 29, 2025
083b133
Fix path
jirispilka Jan 29, 2025
22e4ff0
Fix input
jirispilka Jan 29, 2025
f60a062
Make sure that provided URL is correct
jirispilka Jan 29, 2025
799678e
Add delete conversation
jirispilka Jan 30, 2025
05df1d2
Added error handling
jirispilka Jan 30, 2025
df1b91f
Reorg client.js
jirispilka Jan 30, 2025
7e1d167
Fix
jirispilka Jan 30, 2025
9ad6ff0
Fix
jirispilka Jan 30, 2025
29dd1e0
Fix
jirispilka Jan 30, 2025
4933cf2
Add logging
jirispilka Jan 30, 2025
3f3ebb1
Update README.md
jirispilka Jan 30, 2025
d267810
Add logging
jirispilka Jan 30, 2025
5b66e4d
Comment out the badge
jirispilka Jan 31, 2025
eaad24f
Wait longer on reconnecting
jirispilka Jan 31, 2025
ca1cc7a
Fix readme, remove async from processInput function
jirispilka Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .actor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Specify the base Docker image. You can read more about
# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM apify/actor-node:20 AS builder

# Check preinstalled packages
RUN npm ls crawlee apify puppeteer playwright

# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./

# Install all dependencies. Don't audit to speed up the installation.
RUN npm install --include=dev --audit=false

# Next, copy the source files using the user set
# in the base image.
COPY . ./

# Install all dependencies and build the project.
# Don't audit to speed up the installation.
RUN npm run build

# Create final image
FROM apify/actor-node:20

# Check preinstalled packages
RUN npm ls crawlee apify puppeteer playwright

# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./

# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm

# Copy built JS files from builder image
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/src/public ./dist/public

# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./

# Run the image.
CMD ["npm", "run", "start:prod", "--silent"]
9 changes: 9 additions & 0 deletions .actor/actor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"actorSpecification": 1,
"name": "apify-mcp-client",
"title": "Model Context Protocol Client for Apify Actors",
"description": "Client for the Model Context Protocol (MCP) for Apify Actors",
"version": "0.1",
"input": "./input_schema.json",
"dockerfile": "./Dockerfile"
}
83 changes: 83 additions & 0 deletions .actor/input_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"title": "Apify MCP Client",
"type": "object",
"schemaVersion": 1,
"properties": {
"mcpSseUrl": {
"title": "MCP Server Sent Events (SSE) URL",
"type": "string",
"description": "MCP Server Sent Events (SSE) URL for receiving updates from the server.\n\nMake sure that URL path ends with `/sse`",
"editor": "textfield",
"default": "https://actors-mcp-server.apify.actor/sse?enableActorAutoLoading=true",
"prefill": "https://actors-mcp-server.apify.actor/sse?enableActorAutoLoading=true"
},
"headers": {
"title": "HTTP headers",
"type": "object",
"description": "HTTP headers to be sent with the request to the MCP server. If you are using Apify's MCP server, headers are NOT required",
"editor": "json"
},
"systemPrompt": {
"title": "System prompt",
"type": "string",
"description": "System prompt for the Claude model",
"editor": "textarea",
"default": "You are a helpful Apify assistant with to tools called Actors\n\nYour goal is to help users discover the best Actors for their needs\nYou have access to a list of tools that can help you to discover Actor, find details and include them among tools for later execution\n\nChoose the appropriate tool based on the user's question. If no tool is needed, reply directly.\n\nPrefer Actors with more users, stars, and runs\nWhen you need to use a tool, explain how the tools was used and with which parameters\nNever call a tool unless it is required by user!\nAfter receiving a tool's response:\n1. Transform the raw data into a natural, conversational response\n2. Keep responses concise but informative\n3. Focus on the most relevant information\n4. Use appropriate context from the user's question\n5. Avoid simply repeating the raw data\nAlways use Actor not actor. Provide an URL to Actor whenever possible such as [apify_rag-web-browser](https://apify.com/apify/rag-web-browser).\nREMEMBER Always limit number of results returned from Actors/tools.\nThere is always parameter such as maxResults=1, maxPage=1, maxCrawledPlacesPerSearch=1, keep it to minimal value. \nOtherwise tool execution takes long and result is huge!\n",
"prefill": "You are a helpful Apify assistant with to tools called Actors\n\nYour goal is to help users discover the best Actors for their needs\nYou have access to a list of tools that can help you to discover Actor, find details and include them among tools for later execution\n\nChoose the appropriate tool based on the user's question. If no tool is needed, reply directly.\n\nPrefer Actors with more users, stars, and runs\nWhen you need to use a tool, explain how the tools was used and with which parameters\nNever call a tool unless it is required by user!\nAfter receiving a tool's response:\n1. Transform the raw data into a natural, conversational response\n2. Keep responses concise but informative\n3. Focus on the most relevant information\n4. Use appropriate context from the user's question\n5. Avoid simply repeating the raw data\nAlways use Actor not actor. Provide an URL to Actor whenever possible such as [apify_rag-web-browser](https://apify.com/apify/rag-web-browser).\nREMEMBER Always limit number of results returned from Actors/tools.\nThere is always parameter such as maxResults=1, maxPage=1, maxCrawledPlacesPerSearch=1, keep it to minimal value. \nOtherwise tool execution takes long and result is huge!\n"
},
"modelName": {
"title": "Anthropic Claude model (Anthropic is only supported provider now)",
"type": "string",
"description": "Select a model to be used for selecting tools and generating text.\n\n- Claude 3.5 Sonnet (2024-10-22) - the most intelligent model\n- Claude 3.5 Haiku (2024-10-22) - a fastest model\n- Claude 3 Haiku (2024-03-07) - a fastest and most compact model for near-instant responsiveness",
"editor": "select",
"enum": [
"claude-3-5-sonnet-20241022",
"claude-3-5-haiku-20241022",
"claude-3-haiku-20240307"
],
"enumTitles": [
"Claude 3.5 Sonnet (2024-10-22)",
"Claude 3.5 Haiku (2024-10-22)",
"Claude 3 Haiku (2024-03-07)"
],
"default": "claude-3-5-sonnet-20241022"
},
"llmProviderApiKey": {
"title": "LLM Provider API key (Anthropic is only supported provider now)",
"type": "string",
"description": "API key for accessing a Large Language Model",
"editor": "textfield",
"isSecret": true
},
"modelMaxOutputTokens": {
"title": "Maximum tokens for Claude response",
"type": "integer",
"description": "Maximum number of tokens in the Claude response. The higher the number, the longer the response time",
"editor": "number",
"prefill": 2048,
"default": 2048,
"maximum": 10000
},
"maxNumberOfToolCalls": {
"title": "Maximum number of tool calls",
"type": "integer",
"description": "Maximum number of times a tool can be called in a single request. Keep this number low for simple flows",
"editor": "number",
"prefill": 5,
"default": 5
},
"toolCallTimeoutSec": {
"title": "Tool call timeout",
"type": "integer",
"description": "Timeout for a single tool call in seconds",
"editor": "number",
"prefill": 120,
"default": 120
}
},
"required": [
"mcpSseUrl",
"modelName",
"llmProviderApiKey"
]
}
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# configurations
.idea

# crawlee and apify storage folders
apify_storage
crawlee_storage
storage
src/storage

# installed files
node_modules

# git folder
.git

# data
data
dist
.env
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APIFY_TOKEN=
LLM_PROVIDER_API_KEY=
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file tells Git which files shouldn't be added to source control

.idea
.vscode
storage
apify_storage
crawlee_storage
node_modules
dist
tsconfig.tsbuildinfo
storage/*
!storage/key_value_stores
storage/key_value_stores/*
!storage/key_value_stores/default
storage/key_value_stores/default/*
!storage/key_value_stores/default/INPUT.json

# Added by Apify CLI
.venv
.env
Loading
Loading