Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file added .atom8n/.gitignore
Empty file.
36 changes: 36 additions & 0 deletions .atom8n/My Board.kanban
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"readme": "To open this file inside VSCode, you need to install VSCode extension \"Kanban atom8n\"",
"columns": [
{
"id": "col_x9l30q_mh2u29nh",
"title": "To Do",
"order": 0,
"boardId": "",
"tasks": [
{
"id": "task_10wobx_mh2u6rgp",
"title": "Add tool get token",
"description": "beside cookie tool, get **x-csrf-token** \n\nSteps:\n\n1. Enable network capture\n2. Goto <https://episerver.zendesk.com/agent/search/1>\n3. Capture the request <https://episerver.zendesk.com/api/graphql>\n4. Get its **x-csrf-token** value from request header",
"priority": "MEDIUM",
"order": 0,
"columnId": "col_x9l30q_mh2u29nh",
"assigneeId": null
}
]
},
{
"id": "col_dmru2k_mh2u29nh",
"title": "In Progress",
"order": 1,
"boardId": "",
"tasks": []
},
{
"id": "col_j4m4kk_mh2u29nh",
"title": "Done",
"order": 2,
"boardId": "",
"tasks": []
}
]
}
104 changes: 104 additions & 0 deletions app/chrome-extension/entrypoints/background/tools/browser/cookie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { createErrorResponse, ToolResult } from '@/common/tool-handler';
import { BaseBrowserToolExecutor } from '../base-browser';
import { TOOL_NAMES } from 'chrome-mcp-shared';

interface GetCookieToolParams {
url: string;
}

/**
* Tool for getting cookies from a specified website
*/
class GetCookieTool extends BaseBrowserToolExecutor {
name = TOOL_NAMES.BROWSER.GET_COOKIE;

async execute(args: GetCookieToolParams): Promise<ToolResult> {
const { url } = args;

console.log(`Attempting to get cookies from URL: ${url}`);

try {
// Validate URL format
if (!url || !url.startsWith('http')) {
return createErrorResponse('Valid URL starting with http:// or https:// is required');
}

// Parse the URL to get the domain
let domain: string;
try {
const urlObj = new URL(url);
domain = urlObj.hostname;
} catch (error) {
return createErrorResponse('Invalid URL format provided');
}

console.log(`Getting cookies for domain: ${domain}`);

// Get all cookies for the domain
const cookies = await chrome.cookies.getAll({ domain });

if (!cookies || cookies.length === 0) {
return {
content: [
{
type: 'text',
text: JSON.stringify({
success: true,
message: `No cookies found for domain: ${domain}`,
url: url,
domain: domain,
cookies: [],
cookieString: '',
}),
},
],
isError: false,
};
}

// Format cookies as a string (similar to document.cookie format)
const cookieStrings = cookies.map((cookie) => {
// Handle cookies with empty values
const value = cookie.value || '';
return `${cookie.name}=${value}`;
});

const cookieString = cookieStrings.join('; ');

console.log(`Found ${cookies.length} cookies for domain: ${domain}`);

return {
content: [
{
type: 'text',
text: JSON.stringify({
success: true,
message: `Successfully retrieved ${cookies.length} cookies from ${domain}`,
url: url,
domain: domain,
cookies: cookies.map((cookie) => ({
name: cookie.name,
value: cookie.value,
domain: cookie.domain,
path: cookie.path,
secure: cookie.secure,
httpOnly: cookie.httpOnly,
expirationDate: cookie.expirationDate,
sameSite: cookie.sameSite,
})),
cookieString: cookieString,
}),
},
],
isError: false,
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
console.error(`Error getting cookies for URL ${url}:`, errorMessage);

return createErrorResponse(`Failed to get cookies: ${errorMessage}`);
}
}
}

export const getCookieTool = new GetCookieTool();
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export { historyTool } from './history';
export { bookmarkSearchTool, bookmarkAddTool, bookmarkDeleteTool } from './bookmark';
export { injectScriptTool, sendCommandToInjectScriptTool } from './inject-script';
export { consoleTool } from './console';
export { getCookieTool } from './cookie';
export { fileUploadTool } from './file-upload';
1 change: 1 addition & 0 deletions app/chrome-extension/wxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default defineConfig({
'bookmarks',
'offscreen',
'storage',
'cookies',
],
host_permissions: ['<all_urls>'],
web_accessible_resources: [
Expand Down
Loading